-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ci): better release workflow
- Loading branch information
Showing
9 changed files
with
325 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Comment issue | ||
description: Create comment on a issue | ||
|
||
inputs: | ||
issue_number: | ||
required: true | ||
description: The issue number you want to comment | ||
content: | ||
required: true | ||
description: The content of comment | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/github-script@v7 | ||
env: | ||
STDOUT: ${{ inputs.content }} | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: ${{ inputs.issue_number }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: process.env.STDOUT | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build Done | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
required: true | ||
type: string | ||
dry_run: | ||
required: true | ||
type: boolean | ||
issue_number: | ||
required: true | ||
type: number | ||
|
||
jobs: | ||
tagging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- 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 }}. | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build Pre Tagging | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
dry_run: | ||
required: true | ||
type: boolean | ||
issue_number: | ||
required: true | ||
type: number | ||
outputs: | ||
version: | ||
description: 'Version' | ||
value: ${{ jobs.tagging.outputs.version }} | ||
|
||
jobs: | ||
tagging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get release version | ||
run: | | ||
# `github.head_ref` only exists for pull_request events | ||
REF="${{ github.head_ref || github.ref }}" | ||
VERSION="${REF#release/}" | ||
VERSION="${VERSION#refs/tags/}" | ||
echo "Version: $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Invalid version format: $VERSION, please check git ref or tag." | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create Tag | ||
run: | | ||
if [ ! $(git tag -l "${VERSION}") ]; then | ||
git config user.name github-actions[bot] | ||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
git tag -a $VERSION -m "Release $VERSION" | ||
git push origin $VERSION | ||
else | ||
echo "Skip creating tag $VERSION, already exists." | ||
fi | ||
- name: Comment tag info to PR | ||
uses: ./.github/actions/comment | ||
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). | ||
outputs: | ||
version: ${{ env.VERSION }} |
Oops, something went wrong.