From 60e0e7e61a412b678d9666f059a26d86e19788f9 Mon Sep 17 00:00:00 2001 From: qwqcode Date: Sat, 23 Dec 2023 01:14:40 +0800 Subject: [PATCH] chore(ci): fixed tag version for git checkout branch --- .github/workflows/build-app.yml | 4 +++- .github/workflows/build-docker.yml | 2 ++ .github/workflows/build-done.yml | 9 +++++---- .github/workflows/build-tagging.yml | 4 ++-- .github/workflows/build-ui.yml | 2 ++ .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 8 ++++++-- 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index 1d417c2c3..fc29a2416 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -24,6 +24,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: + ref: ${{ inputs.version }} + # `go-releaser` will read the semver version from git tag name + # `git-chglog` will diff the tag and generate changelog fetch-depth: 0 # disable cache because the err `no space left on device` @@ -78,7 +81,6 @@ jobs: -v $(pwd):/go/src/${PKG_NAME} \ -w /go/src/${PKG_NAME} \ -e CGO_ENABLED=1 \ - -e VERSION=${{ inputs.version }} \ --env-file local/.release-env \ ghcr.io/goreleaser/goreleaser-cross:v${GO_VERSION} \ release --release-notes local/release-notes.md ${{ inputs.dry_run && '--skip=publish' || '' }} diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 81e3f75a8..ac316ea35 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + ref: ${{ inputs.version }} # https://github.com/docker/metadata-action - name: Gen docker meta diff --git a/.github/workflows/build-done.yml b/.github/workflows/build-done.yml index 32be42477..c07040acd 100644 --- a/.github/workflows/build-done.yml +++ b/.github/workflows/build-done.yml @@ -14,17 +14,18 @@ on: type: number jobs: - tagging: + done: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 + with: + ref: ${{ inputs.version }} - name: Comment done info uses: ./.github/actions/comment if: ${{ inputs.issue_number != 0 }} with: issue_number: ${{ inputs.issue_number }} - content: | - 🎉 Finished build and publish version ${{ inputs.version }}. - + content: |- + 🎉 Finished build and publish ${{ inputs.version }} ([NPM Package](https://www.npmjs.com/package/artalk?activeTab=versions) / [Docker Image](https://hub.docker.com/r/artalk/artalk-go/tags) / [Github Release](https://github.com/ArtalkJS/Artalk/releases/tag/${{ inputs.version }})). diff --git a/.github/workflows/build-tagging.yml b/.github/workflows/build-tagging.yml index 649fb1c13..a6a6204fa 100644 --- a/.github/workflows/build-tagging.yml +++ b/.github/workflows/build-tagging.yml @@ -54,7 +54,7 @@ jobs: if: ${{ inputs.issue_number != 0 }} with: issue_number: ${{ inputs.issue_number }} - content: | - 🔖 Tagged version [${{ env.VERSION }}](https://github.com/ArtalkJS/Artalk/tree/${{ env.VERSION }}), also see [CHANGELOG.md](https://github.com/ArtalkJS/Artalk/blob/master/CHANGELOG.md). + content: |- + 🔖 Tagged version [${{ env.VERSION }}](https://github.com/ArtalkJS/Artalk/tree/${{ env.VERSION }}) and updated the [CHANGELOG.md](https://github.com/ArtalkJS/Artalk/blob/master/CHANGELOG.md). outputs: version: ${{ env.VERSION }} diff --git a/.github/workflows/build-ui.yml b/.github/workflows/build-ui.yml index 9c3511925..a0495aea4 100644 --- a/.github/workflows/build-ui.yml +++ b/.github/workflows/build-ui.yml @@ -17,6 +17,8 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + ref: ${{ inputs.version }} - name: Use pnpm uses: pnpm/action-setup@v2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57efae51a..b878c0545 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: dry_run: description: 'Dry run' type: boolean - default: false + default: true build_items: description: 'Build items' type: string diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d95521a12..1a5d5872e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: + ref: master fetch-depth: 0 - name: Setup Node @@ -32,6 +33,9 @@ jobs: node-version: 18.x registry-url: https://registry.npmjs.org/ + - name: Setup semver + run: npm install -g semver + - name: Handle Version Number run: | PREV_VERSION="$(git describe --tags --abbrev=0)" @@ -66,13 +70,14 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v5 + if: ${{ !inputs.dry_run }} with: branch: "release/${{ env.VERSION }}" commit-message: "chore: release ${{ env.VERSION }}" title: "chore: release ${{ env.VERSION }}" labels: release body: | - # Release ${{ env.VERSION }} 📦🚀 + ## Release ${{ env.VERSION }} 📦🚀 This PR is auto-generated, please check the changelog and confirm the release. 😀 @@ -80,4 +85,3 @@ jobs: committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> assignees: ${{ github.actor }} - draft: ${{ inputs.dry_run }}