diff --git a/.github/workflows/release-and-tag.yml b/.github/workflows/release-and-tag.yml new file mode 100644 index 00000000..a9207085 --- /dev/null +++ b/.github/workflows/release-and-tag.yml @@ -0,0 +1,54 @@ +name: Create new release on version bump + +permissions: + contents: write + +on: + push: { branches: ["main"] } + +jobs: + check-release: + name: Create release if it makes sense + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Check if a new release is needed + id: info + env: + COMMIT_BEFORE: ${{ github.event.before }} + COMMIT_AFTER: ${{ github.event.after }} + shell: bash + run: | + mkdir -p dummy && echo 0 > dummy/revision.txt + cp utils/helium_version.py . + + git checkout "$COMMIT_BEFORE" \ + && OLD_VERSION=$(python3 helium_version.py --tree . --print) + + git checkout "$COMMIT_AFTER" \ + && NEW_VERSION=$(python3 helium_version.py --tree . --print) + + if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then + echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + { + printf '### Changelog\n```\n' + git log --oneline "$COMMIT_BEFORE..$COMMIT_AFTER" + echo '```' + } | tee body.md + fi + + - name: Create Release + if: steps.info.outputs.version + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.info.outputs.version }} + release_name: ${{ steps.info.outputs.version }} + body_path: body.md + draft: false + prerelease: false diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml deleted file mode 100644 index 4f06f7d3..00000000 --- a/.github/workflows/release-on-tag.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Create new empty release -permissions: - contents: write - -on: - push: - tags: - - '*' - -jobs: - build: - name: Create Release - runs-on: ubuntu-latest - steps: - - name: Create Release - id: create_release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false