Merge pull request #151 from oscarbenjamin/pr_pyright #125
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 | |
- master | |
jobs: | |
tag-and-build: | |
name: Tag and build | |
runs-on: ubuntu-latest | |
permissions: write-all | |
outputs: | |
tag: ${{ steps.tag-step.outputs.tag }} | |
steps: | |
- name: Check out the repository | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 2 | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: "3.12" | |
- name: Upgrade pip | |
run: | | |
pip install --upgrade pip | |
pip install hatch | |
- name: Check if there is a parent commit | |
id: check-parent-commit | |
run: | | |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT | |
- name: Detect and tag new version | |
id: check-version | |
if: steps.check-parent-commit.outputs.sha | |
uses: salsify/action-detect-and-tag-new-version@v2 | |
with: | |
version-command: | | |
hatch version | |
- name: Bump version for developmental release | |
if: "! steps.check-version.outputs.tag" | |
run: | | |
hatch version dev && | |
version=$(hatch version) && | |
hatch version $version$(date +%s) | |
- name: Publish the release notes | |
uses: release-drafter/[email protected] | |
with: | |
publish: ${{ steps.check-version.outputs.tag != '' }} | |
tag: ${{ steps.check-version.outputs.tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build package | |
run: | | |
hatch build | |
- name: Store tag | |
id: tag-step | |
run: echo "tag=${{ steps.check-version.outputs.tag }}" >> "$GITHUB_OUTPUT" | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifacts | |
path: dist/ | |
test-pypi-publish: | |
name: Publish to Test-PyPI | |
needs: [tag-and-build] | |
if: "! needs.tag-and-build.outputs.tag" | |
environment: | |
name: test-pypi | |
url: https://test.pypi.org/p/protosym | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download release artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-artifacts | |
path: dist | |
- name: Publish package on TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
pypi-publish: | |
name: Publish to PyPI | |
needs: [tag-and-build] | |
if: needs.tag-and-build.outputs.tag | |
environment: | |
name: pypi | |
url: https://pypi.org/p/protosym | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download release artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-artifacts | |
path: dist | |
- name: Publish package on PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |