Skip to content

Commit

Permalink
Merge pull request #42 from yuma140902/gha-release
Browse files Browse the repository at this point in the history
ci: update release workflow
  • Loading branch information
yuma140902 authored Oct 15, 2023
2 parents 2a2612c + 3b2e0a1 commit da9538e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 43 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Generate changelog before release.yml

on:
pull_request:
type:
- opened

env:
PJ_NAME: tempura

jobs:
changelog:
name: Generate and commit changelog for ${{ github.head_ref }}
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release/')
outputs:
changelog: ${{ steps.changelog.outputs.changes }}
steps:
- name: Setup | Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Parse version
run: |
ref=${{ github.head_ref }}
version=${ref#release/}
echo "Version=$version" >> $GITHUB_ENV
- name: Setup | Go
uses: actions/setup-go@v3

- name: Setup | Install git-chglog
run: go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest

- name: Generate changelog
run: |
/home/runner/go/bin/git-chglog ${{ env.Version }} | tee RELEASE_NOTE.md
/home/runner/go/bin/git-chglog ..${{ env.Version }} | tee CHANGELOG.md
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: 'doc: update CHANGELOG.md for ${{ env.Version }} [skip ci]'
file_pattern: CHANGELOG.md
tagging_message: ${{ env.Version }}

- name: Post comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.pull_request.html_url }}
run:
gh pr comment -F RELEASE_NOTE.md "${URL}"

- name: Upload CHANGELOG-${{ env.Version }}.md
uses: actions/upload-artifact@v3
with:
name: release-note
path: RELEASE_NOTE.md

- name: Upload CHANGELOG.md
uses: actions/upload-artifact@v3
with:
name: changelog-all
path: CHANGELOG.md
50 changes: 7 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
tags:
- 'v*.*.*'
branches:
- master

env:
# Disable incremental build
Expand Down Expand Up @@ -87,60 +89,22 @@ jobs:
name: ${{ env.PJ_NAME }}-${{ matrix.target }}.zip
path: ${{ env.PJ_NAME }}-${{ matrix.target }}.zip

changelog:
name: Generate and commit changelog for ${{ github.ref_name }}
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.changelog.outputs.changes }}
steps:
- name: Setup | Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup | Go
uses: actions/setup-go@v3

- name: Setup | Install git-chglog
run: go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest

- name: Generate changelog
run: |
/home/runner/go/bin/git-chglog ${{ github.ref_name }} | tee CHANGELOG-${{ github.ref_name }}.md
/home/runner/go/bin/git-chglog ..${{ github.ref_name }} | tee CHANGELOG.md
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: master
commit_message: 'doc: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
file_pattern: CHANGELOG.md

- name: Upload CHANGELOG-${{ github.ref_name }}.md
uses: actions/upload-artifact@v3
with:
name: changelog
path: CHANGELOG-${{ github.ref_name }}.md

- name: Upload CHANGELOG.md
uses: actions/upload-artifact@v3
with:
name: changelog-all
path: CHANGELOG.md

github_release:
name: Make a new GitHub release for ${{ github.ref_name }}
needs: [build, changelog]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: dawidd6/action-download-artifact@v2
with:
workflow: pre-release.yml
workflow_conclusion: success

- name: Add Artifacts to Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PJ_NAME }}-*/${{ env.PJ_NAME }}-*
body_path: changelog/CHANGELOG-${{ github.ref_name }}.md
body_path: release-note/RELEASE_NOTE.md
tag_name: ${{ github.ref_name }}

crates_io_publish:
Expand Down

0 comments on commit da9538e

Please sign in to comment.