diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml index fc58018..d090735 100644 --- a/.github/workflows/bump.yaml +++ b/.github/workflows/bump.yaml @@ -23,32 +23,35 @@ jobs: - id: bump-version run: | cz bump --yes - current_version="v$(cz version -p)" + + new_version="v$(cz version -p)" major_version="v$(cz version -p --major)" - echo "current_version=$current_version" >> $GITHUB_OUTPUT + new_version_tag="$(cz version -p --tag)" + + echo "new_version=$new_version" >> $GITHUB_OUTPUT echo "major_version=$major_version" >> $GITHUB_OUTPUT + echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT - name: Update major tag env: - CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }} + NEW_VERSION: ${{ steps.bump-version.outputs.new_version }} MAJOR_VERSION: ${{ steps.bump-version.outputs.major_version }} run: | # Push new commit + new tag git push --follow-tags # Move major tag to the latest commit - git tag -fa "${MAJOR_VERSION}" -m "release ${CURRENT_VERSION}" + git tag -fa "${MAJOR_VERSION}" -m "release ${NEW_VERSION}" # Force push new major tag git push origin "${MAJOR_VERSION}" -f - name: Build changelog env: - CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }} + NEW_VERSION: ${{ steps.bump-version.outputs.new_version }} run: | - cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md + cz changelog --dry-run "${NEW_VERSION}" > .changelog.md - name: Release - uses: softprops/action-gh-release@v2 - with: - body_path: ".changelog.md" - tag_name: ${{ steps.bump-version.outputs.current_version }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} + NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }} + run: | + gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md diff --git a/examples/bump-release.yaml b/examples/bump-release.yaml index 1c92f1b..3c2c7aa 100644 --- a/examples/bump-release.yaml +++ b/examples/bump-release.yaml @@ -24,17 +24,18 @@ jobs: run: | cz bump --yes --annotated-tag git push --follow-tags - current_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version - echo "current_version=$current_version" >> $GITHUB_OUTPUT + new_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version + new_version_tag="$(cz version -p --tag)" + echo "new_version=$new_version" >> $GITHUB_OUTPUT + echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT - name: Build changelog for Release env: - CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }} + NEW_VERSION: ${{ steps.bump-version.outputs.new_version }} run: | - cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md + cz changelog --dry-run "${NEW_VERSION}" > .changelog.md - name: Release - uses: softprops/action-gh-release@v2 - with: - body_path: ".changelog.md" - tag_name: ${{ steps.bump-version.outputs.current_version }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} + NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }} + run: | + gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md diff --git a/examples/trigger-other-job/.github/workflows/README.md b/examples/trigger-other-job/.github/workflows/README.md index bcb297b..ec81736 100644 --- a/examples/trigger-other-job/.github/workflows/README.md +++ b/examples/trigger-other-job/.github/workflows/README.md @@ -19,7 +19,7 @@ flowchart LR release --> workflow_dispatch end - subgraph TM["trigger-me"] + subgraph TM["release"] echo_version["echo version"] end diff --git a/examples/trigger-other-job/.github/workflows/bump-release.yaml b/examples/trigger-other-job/.github/workflows/bump-release.yaml index 08333d7..f6db9d6 100644 --- a/examples/trigger-other-job/.github/workflows/bump-release.yaml +++ b/examples/trigger-other-job/.github/workflows/bump-release.yaml @@ -22,25 +22,29 @@ jobs: python-version: "3.x" - id: bump-version run: | + old_version="$(cz version -p)" cz bump --yes --annotated-tag git push --follow-tags - current_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version - echo "current_version=$current_version" >> $GITHUB_OUTPUT + new_version="$(cz version -p)" + new_version_tag="$(cz version -p --tag)" + + echo "old_version=$old_version" >> $GITHUB_OUTPUT + echo "new_version=$new_version" >> $GITHUB_OUTPUT + echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT - name: Build changelog for Release env: - CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }} + NEW_VERSION: ${{ steps.bump-version.outputs.new_version }} run: | - cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md + cz changelog --dry-run "${NEW_VERSION}" > .changelog.md - name: Release - uses: softprops/action-gh-release@v2 - with: - body_path: ".changelog.md" - tag_name: ${{ steps.bump-version.outputs.current_version }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} + NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }} + run: | + gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md - name: trigger other workflow env: GH_TOKEN: ${{ github.token }} run: | - gh workflow run .github/workflows/trigger-me.yaml \ - -f "version=${{ steps.bump-version.outputs.current_version }}" + gh workflow run release.yaml \ + -f "version=${{ steps.bump-version.outputs.new_version_tag }}" diff --git a/examples/trigger-other-job/.github/workflows/trigger-me.yaml b/examples/trigger-other-job/.github/workflows/release.yaml similarity index 63% rename from examples/trigger-other-job/.github/workflows/trigger-me.yaml rename to examples/trigger-other-job/.github/workflows/release.yaml index 9fa9d2a..a555a59 100644 --- a/examples/trigger-other-job/.github/workflows/trigger-me.yaml +++ b/examples/trigger-other-job/.github/workflows/release.yaml @@ -6,9 +6,14 @@ on: required: true jobs: - triggered-echo: + release: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: ${{ inputs.version }} - name: Trigger other job run: | echo "Version: ${{ inputs.version }}" diff --git a/flake.lock b/flake.lock index cb6b9ff..bacdd6e 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1762980239, - "narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=", + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "52a2caecc898d0b46b2b905f058ccc5081f842da", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", "type": "github" }, "original": { @@ -19,11 +19,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1763464769, - "narHash": "sha256-AJHrsT7VoeQzErpBRlLJM1SODcaayp0joAoEA35yiwM=", + "lastModified": 1774855581, + "narHash": "sha256-YkreHeMgTCYvJ5fESV0YyqQK49bHGe2B51tH6claUh4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6f374686605df381de8541c072038472a5ea2e2d", + "rev": "15c6719d8c604779cf59e03c245ea61d3d7ab69b", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1761765539, - "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "lastModified": 1772328832, + "narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742", "type": "github" }, "original": {