Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading changelog - automate release bodies #192

Open
joepio opened this issue Nov 25, 2021 · 1 comment
Open

Reading changelog - automate release bodies #192

joepio opened this issue Nov 25, 2021 · 1 comment
Labels
type: feature request New feature or request

Comments

@joepio
Copy link

joepio commented Nov 25, 2021

Hi there! Thanks for creating and maintaining this.

I recently came across this github action: create-gh-release-action, which parses the CHANGELOG.md file and uses that to create a body for the release.

Might be cool this action supports a similar thing.

Users can also manually set it up using changelog-reader:

      - name: Get Changelog Entry
        id: changelog_reader
        uses: mindsers/changelog-reader-action@v2
        with:
          validation_depth: 10
          version: ${{ steps.tag_name.outputs.current_version }}
          path: ./CHANGELOG.md
      - name: Create/update release
        uses: ncipollo/release-action@v1
        with:
          # This pulls from the "Get Changelog Entry" step above, referencing it's ID to get its outputs object.
          # See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
          tag: ${{ steps.changelog_reader.outputs.version }}
          name: Release ${{ steps.changelog_reader.outputs.version }}
          body: ${{ steps.changelog_reader.outputs.changes }}
          prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
          draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
          allowUpdates: true
          token: ${{ secrets.GITHUB_TOKEN }}

But it would be even better if this was natively supported by this action.

@FabianLars FabianLars added the type: feature request New feature or request label Feb 6, 2023
@xendarboh
Copy link

I came across this issue while automating release bodies with a changelog generated from git commits since previous release. Thought I'd share my experience and the resulting workflow.

In my case, I found the tauri-action configuration flexibility sufficient, as there are many compatible changelog-producing actions or tools. If anything, perhaps a suggestion for this issue is a publish-to-auto-release-tag-with-changelog.yml documentation example. tauri-action works great!

For the following workflow, pushed git tags trigger releases while git-cliff generates the changelog for release body from latest (unreleased) commits.

Resulting workflow file
# - remove version from `tauri.conf.json` so it's managed by `Cargo.toml`
# - create git-cliff's `cliff.toml` config file with `git cliff --init`
name: "publish"

on:
  push:
    tags:
      - "v*"

# On each push of a `v*` git tag it will create or update a GitHub release with a generated changelog, build your app, and upload the artifacts to the release.

jobs:
  publish-tauri:
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: "macos-latest" # for Arm based macs (M1 and above).
            args: "--target aarch64-apple-darwin"
          - platform: "macos-latest" # for Intel based macs.
            args: "--target x86_64-apple-darwin"
          - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
            args: ""
          - platform: "windows-latest"
            args: ""

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: lts/*

      - name: install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
          targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
        # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
        # You can remove the one that doesn't apply to your app to speed up the workflow a bit.

      - name: install frontend dependencies
        run: npm install # change this to npm, pnpm or bun depending on which one you use.

      - name: Extract version from tag
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
        shell: bash

      # for cross-platform build compat, use perl
      - name: Update the Tauri App version with tag version
        run: |
          perl -pi -e 's/^version = ".*"/version = "${{ env.VERSION }}"/' src-tauri/Cargo.toml

      - name: install git-cliff
        run: cargo install git-cliff || true

      - name: generate changelog
        id: changelog
        run: |
          echo 'changelog<<EOF' >> $GITHUB_OUTPUT
          git-cliff --latest --strip all --use-branch-tags >> $GITHUB_OUTPUT
          echo 'EOF' >> $GITHUB_OUTPUT

      - uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tagName: v${{ env.VERSION }}
          releaseName: v${{ env.VERSION }}
          releaseBody: "${{ steps.changelog.outputs.changelog }}"
          releaseDraft: true
          prerelease: true
          args: ${{ matrix.args }}

Changes to examples/publish-to-auto-release.yml:

 name: "publish"
 
 on:
   push:
-    branches:
-      - release
+    tags:
+      - "v*"
 
 # This is the example from the readme.
 # On each push to the `release` branch it will create or update a GitHub release, build your app, and upload the artifacts to the release.
@@ -28,6 +29,9 @@ jobs:
     runs-on: ${{ matrix.platform }}
     steps:
       - uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          fetch-tags: true
 
       - name: setup node
         uses: actions/setup-node@v4
@@ -49,15 +53,34 @@ jobs:
         # You can remove the one that doesn't apply to your app to speed up the workflow a bit.
 
       - name: install frontend dependencies
         run: yarn install # change this to npm, pnpm or bun depending on which one you use.
+
+      - name: Extract version from tag
+        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
+        shell: bash
+
+      # for cross-platform build compat, use perl
+      - name: Update the Tauri App version with tag version
+        run: |
+          perl -pi -e 's/^version = ".*"/version = "${{ env.VERSION }}"/' src-tauri/Cargo.toml
+
+      - name: install git-cliff
+        run: cargo install git-cliff || true
+
+      - name: generate changelog
+        id: changelog
+        run: |
+          echo 'changelog<<EOF' >> $GITHUB_OUTPUT
+          git-cliff --latest --strip all --use-branch-tags >> $GITHUB_OUTPUT
+          echo 'EOF' >> $GITHUB_OUTPUT
 
       - uses: tauri-apps/tauri-action@v0
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         with:
-          tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
-          releaseName: "App v__VERSION__"
-          releaseBody: "See the assets to download this version and install."
+          tagName: v${{ env.VERSION }}
+          releaseName: v${{ env.VERSION }}
+          releaseBody: "${{ steps.changelog.outputs.changelog }}"
           releaseDraft: true
           args: ${{ matrix.args }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants