-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add steps to determine if __version__.py requires modificat…
…ion prior to package release
- Loading branch information
Showing
1 changed file
with
22 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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" | ||
|