Publish #28
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: Publish | |
on: | |
workflow_dispatch: | |
jobs: | |
# ------------- | |
release: | |
name: Create A Release | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
id-token: write | |
outputs: | |
TAG: ${{ steps.semver.outputs.nextStrict }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Personal Access Token enables git push in actions (repo contents permission) | |
token: ${{ secrets.PAT }} | |
- name: Calculate next version | |
id: semver | |
uses: ietf-tools/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- id: current | |
run: echo "version=$(pipx run hatch version | tr -d '\n')" >> $GITHUB_OUTPUT | |
- if: ${{ steps.current.outputs.version == steps.semver.outputs.nextStrict || !steps.current.outputs.version }} | |
run: exit 1 | |
- name: Version Up | |
run: pipx run hatch version ${{ steps.semver.outputs.nextStrict }} | |
- name: Commit version change and tag | |
run: | | |
git config --global user.name 'GitHub Automation' | |
git config --global user.email 'automation[bot]@leocov.com' | |
git add src/pyside_app_core/__init__.py | |
git commit -m "chore(release): version up to: ${{ steps.semver.outputs.nextStrict }} [skip ci]" | |
git push | |
git tag ${{ steps.semver.outputs.nextStrict }} | |
git push --tags | |
- name: Create Build | |
run: pipx run hatch build | |
- name: Generate Build Signatures | |
uses: sigstore/[email protected] | |
with: | |
inputs: ./dist/* | |
- name: Generate Changelog | |
id: changelog | |
uses: requarks/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.semver.outputs.nextStrict }} | |
excludeScopes: "release" | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/*" | |
tag: ${{ steps.semver.outputs.nextStrict }} | |
name: "Release v${{ steps.semver.outputs.nextStrict }}" | |
body: ${{ steps.changelog.outputs.changelog }} | |
# ------------- | |
pypi: | |
name: Publish to PyPi | |
needs: [ release ] | |
permissions: | |
id-token: write | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pyside-app-core | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release download ${{ needs.release.outputs.TAG }} --dir dist -p "*.whl" -p "*.tar.gz" | |
# trusted publishing workflow: | |
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
- name: Publish To PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1.9 | |