ci: add bump release workflow (#222)

* feat: ci update

Signed-off-by: Innei <i@innei.in>

* fix: lockfile

Signed-off-by: Innei <i@innei.in>

---------

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-08-18 20:39:47 +08:00
committed by GitHub
parent 465f1a6acf
commit e7de52eac8
4 changed files with 448 additions and 30 deletions
+16 -27
View File
@@ -2,8 +2,15 @@ name: Build
on:
push:
branches:
- "**"
tags:
- "v*"
workflow_dispatch:
inputs:
tag_version:
description: "Tag Version"
required: true
env:
VITE_WEB_URL: ${{ vars.VITE_WEB_URL }}
VITE_API_URL: ${{ vars.VITE_API_URL }}
@@ -118,17 +125,21 @@ jobs:
path: |
out/make/**/*.dmg
retention-days: 90
- run: npx changelogithub
if: github.ref_type == 'tag' || github.event.inputs.tag_version != ''
continue-on-error: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Setup Version
id: version
uses: ./.github/actions/setup-version
- name: Create Release Draft
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' || github.event.inputs.tag_version != ''
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.version.outputs.APP_VERSION }}
draft: true
prerelease: false
draft: false
prerelease: true
tag_name: v${{ steps.version.outputs.APP_VERSION }}
files: |
out/make/**/*.dmg
@@ -136,25 +147,3 @@ jobs:
out/make/**/*.exe
out/make/**/*.AppImage
out/make/**/*.yml
changelog:
needs: [release]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+48
View File
@@ -0,0 +1,48 @@
name: Tag on SemVer Commit
on:
push:
branches:
- main
jobs:
create_tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Extract SemVer using Node.js
id: extract_semver
run: |
node -e '
const execSync = require("child_process").execSync;
const fs = require("fs");
const commitMessage = execSync("git log -1 --pretty=%B").toString("utf-8");
const semverRegex = /chore: Release (v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-.]+)?)/;
const match = commitMessage.match(semverRegex);
if (match) {
fs.appendFileSync(process.env.GITHUB_ENV, `tag_version=${match[1]}\n`);
} else {
console.log("No SemVer found in commit body.");
process.exit(0);
}
'
- name: Create a new tag
if: ${{ env.tag_version }}
run: |
git tag ${{ env.tag_version }}
git push origin ${{ env.tag_version }}
- name: Trigger Build Workflow
if: ${{ env.tag_version }}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches \
-d '{"ref":"main", "inputs": {"tag_version": "${{ env.tag_version }}"}}'