Merge pull request #123 from communitiesuk/upgrade-version #117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
name: Create a GitHub Release | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get version from package.json | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@main | |
- name: Create a GitHub Release (Fails if release already exists with same version number) | |
uses: actions/github-script@v7 | |
env: | |
package-version: ${{ steps.package-version.outputs.current-version }} | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: 'v' + process.env['package-version'], | |
generate_release_notes: true, | |
}); | |
build-and-publish: | |
needs: Release | |
name: Build and publish package to PyPI and TestPyPI | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
activate-environment: dash_react_components | |
environment-file: environment.yml | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Generate python files | |
run: npm install && npm run build | |
- name: Build a binary wheel and a source tarball | |
run: >- | |
python -m | |
build | |
--sdist | |
--wheel | |
--outdir dist/ | |
. | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |