Skip to content

Commit

Permalink
feat: only trigger release workflow if version has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
cedrictq committed Dec 3, 2024
1 parent 691e677 commit 4af556d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 33 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/create-release.yaml
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 }}
37 changes: 5 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Release

on:
push:
branches:
- main
paths-ignore:
- conda-recipes/deps/**
tags:
- v*

permissions:
contents: read
Expand Down Expand Up @@ -126,8 +124,8 @@ jobs:
path: dist


release:
name: Release
publish:
name: Publish to pypi and terraquantumag channel
runs-on: ubuntu-latest
needs: [build, sdist]
permissions:
Expand Down Expand Up @@ -166,29 +164,4 @@ jobs:
MATURIN_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*

- 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 ${{ steps.pyproject_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: ${{ steps.pyproject_version.outputs.version }}
args: --non-interactive --skip-existing wheels-*/*
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "keygen-py"
version = "0.1.2"
version = "0.1.3"
license = "MIT"
description = "Unofficial Keygen SDK for Python. Integrate license activation and offline licensing. Wrapper around keygen-rs rust crate"
requires-python = ">=3.9"
Expand Down

0 comments on commit 4af556d

Please sign in to comment.