-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: only trigger release workflow if version has changed
- Loading branch information
Showing
3 changed files
with
91 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Create new release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- conda-recipes/deps/** | ||
|
||
|
||
jobs: | ||
check_version: | ||
name: Check version changed | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version_change: ${{ steps.check.outputs.version_change }} | ||
version: ${{ steps.get_current_version.outputs.version }} | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get version from pyproject.toml | ||
id: get_current_version | ||
run: | | ||
version=v$(grep '^version' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
- name: Get latest version | ||
id: get_latest_tag | ||
run: | | ||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | ||
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT | ||
- name: Check Version Change | ||
id: check | ||
run: | | ||
if [ "$VERSION" != "$LATEST_TAG" ]; then | ||
echo "version_change=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "version_change=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
VERSION: ${{ steps.get_current_version.outputs.version }} | ||
LATEST_TAG: ${{ steps.get_latest_tag.outputs.latest_tag }} | ||
|
||
|
||
create_and_release: | ||
runs-on: ubuntu-latest | ||
name: Create new release | ||
needs: check_version | ||
if: ${{ needs.check_version.outputs.version_change == 'true' }} | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build changelog | ||
id: build_changelog | ||
uses: mikepenz/release-changelog-builder-action@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
toTag: ${{ github.sha }} | ||
ignorePreReleases: 'true' | ||
configurationJson: | | ||
{ | ||
"template": "## Release ${{ needs.check_version.outputs.version }}\n\n#{{CHANGELOG}}", | ||
"categories": [ | ||
{ | ||
"title": "### Changes", | ||
"labels": [] | ||
} | ||
] | ||
} | ||
- name: Create release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
body: ${{ steps.build_changelog.outputs.changelog }} | ||
tag_name: ${{ needs.check_version.outputs.version }} |
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
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