Publish #14
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: | ||
# ------------- | ||
version-up: | ||
name: Calculate Next Version | ||
if: github.ref == 'refs/heads/main' | ||
permissions: | ||
contents: write | ||
id-token: write | ||
outputs: | ||
NEXT: ${{ 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/blurhash_pyside/__init__.py | ||
git commit -m "chore(release): version up to: ${{ steps.semver.outputs.nextStrict }}" | ||
git push | ||
git tag ${{ steps.semver.outputs.nextStrict }} | ||
git push --tags | ||
# ------------- | ||
build: | ||
needs: [ version-up ] | ||
uses: ./.github/workflows/_build.yml | ||
with: | ||
ref: "refs/tags/${{ steps.semver.outputs.nextStrict }}" | ||
Check failure on line 59 in .github/workflows/publish.yml GitHub Actions / PublishInvalid workflow file
|
||
# ------------- | ||
release: | ||
name: Create A Release | ||
needs: [ version-up, build ] | ||
permissions: | ||
contents: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: "refs/tags/${{ steps.semver.outputs.nextStrict }}" | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
- name: Display structure of downloaded files | ||
run: ls -R dist/ | ||
- 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: ${{ needs.version-up.outputs.NEXT }} | ||
name: "Release v${{ needs.version-up.outputs.NEXT }}" | ||
body: ${{ steps.changelog.outputs.changelog }} | ||
# ------------- | ||
pypi: | ||
name: Publish to PyPi | ||
needs: [ version-up, build, release ] | ||
permissions: | ||
id-token: write | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/blurhash-pyside | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "refs/tags/${{ steps.semver.outputs.nextStrict }}" | ||
- name: Download Release Assets | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: gh release download ${{ needs.versioon-up.outputs.NEXT }} --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 |