Skip to content

Commit

Permalink
refactor: add steps to determine if __version__.py requires modificat…
Browse files Browse the repository at this point in the history
…ion prior to package release
  • Loading branch information
lpm0073 committed Nov 13, 2023
1 parent b7befd3 commit f53f798
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ jobs:
with:
node-version: '16'

- name: Get current version
id: current_version
run: |
echo "::set-output name=version::$(python -c 'from __version__ import __version__; print(__version__)')"
- name: Get next version
id: next_version
run: |
echo "::set-output name=version::$(npx semantic-release --dry-run | grep 'The next release version is' | cut -d ' ' -f6)"
- name: Update __version__
if: steps.current_version.outputs.version != steps.next_version.outputs.version
run: |
echo "__version__ = '${{ steps.next_version.outputs.version }}'" > __version__.py
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ steps.next_version.outputs.version }}"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
Expand Down Expand Up @@ -55,18 +77,6 @@ jobs:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com

- name: Update __about__
if: steps.semantic.outputs.new_release_published == 'true'
run: |
npx semantic-release exec -- cmd /c "echo __version__ = '${{ steps.semantic.outputs.new_release_version }}' > __version__.py"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ steps.semantic.outputs.new_release_version }}"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: echo "new release was published"
Expand Down

0 comments on commit f53f798

Please sign in to comment.