Skip to content

Commit

Permalink
Merge pull request #270 from callowayproject/fix-release
Browse files Browse the repository at this point in the history
Fixed release workflow
  • Loading branch information
coordt authored Dec 17, 2024
2 parents 5fe8ce5 + c0e7ad4 commit 2fa812c
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
types: [closed]
branches: [master]

workflow_dispatch:
inputs:
releaseType:
Expand All @@ -24,6 +25,10 @@ jobs:
pull-requests: read
contents: write
runs-on: ubuntu-latest
outputs:
release-kind: ${{ steps.release-kind.outputs.release-kind }}
package: ${{ steps.bump-version.outputs.package }}
tag-name: ${{ steps.bump-version.outputs.tag-name }}
steps:
- uses: actions/checkout@v4
name: Checkout the repository
Expand All @@ -45,16 +50,18 @@ jobs:
RELEASE_KIND=$(generate-changelog --output release-hint)
echo "::notice::Suggested release type for this branch is: ${RELEASE_KIND}"
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
echo "PACKAGE=false" >> $GITHUB_ENV
- name: Override release kind on manual
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.releaseType != 'auto' }}
id: override-release-kind
run: |
echo "::notice::Overriding release type to ${{ github.event.inputs.releaseType }} since this was a manual trigger"
echo "RELEASE_KIND=${{ github.event.inputs.releaseType }}" >> $GITHUB_ENV
echo "release-kind=${{ github.event.inputs.releaseType }}" >> $GITHUB_OUTPUT
- name: Output release kind
id: release-kind
run: |
echo "release-kind=${{ env.RELEASE_KIND }}" >> $GITHUB_OUTPUT
- name: Get Pull Request Number
id: pr
Expand All @@ -63,35 +70,43 @@ jobs:
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Bump version
if: ${{ env.RELEASE_KIND != 'no-release' }}
id: bump-version
shell: bash
run: |
case "$RELEASE_KIND" in
major|minor|patch)
bump-my-version bump --allow-dirty --verbose "$RELEASE_KIND"
echo "TAG_NAME=$(bump-my-version show current_version)" >> $GITHUB_ENV
export "TAG_NAME=$(bump-my-version show current_version)"
git push
git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
export PACKAGE=true
;;
dev)
bump-my-version bump --allow-dirty --verbose --no-commit --no-tag "$RELEASE_KIND"
echo "PACKAGE=true" >> $GITHUB_ENV
export PACKAGE=true
;;
*)
echo "PACKAGE=false" >> $GITHUB_ENV
export PACKAGE=false
esac
echo "package=$PACKAGE" >> $GITHUB_OUTPUT
echo "tag-name=$TAG_NAME" >> $GITHUB_OUTPUT
- name: Package and upload artifacts
if: ${{ env.PACKAGE == 'true' }}
uses: ./.github/actions/package-and-upload-artifacts
with:
tag-name: ${{ env.TAG_NAME }}

release:
if: ${{ env.PACKAGE == 'true' }}
if: needs.version.outputs.package == 'true'
needs: version
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -113,13 +128,8 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: "${{ env.TAG_NAME }}"
tag_name: "${{ needs.version.outputs.tag-name }}"
body_path: release-notes.md

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create a GitHub release
uses: ./.github/actions/release
with:
tag-name: ${{ env.TAG_NAME }}

0 comments on commit 2fa812c

Please sign in to comment.