ci: merge ci workflows

This commit is contained in:
mirtlecn 2024-08-20 13:04:34 +08:00
parent 7942d9c328
commit 63671a96a9
2 changed files with 39 additions and 59 deletions

View File

@ -1,48 +0,0 @@
name: Check and Build
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, ' [build]') }}
steps:
- name: Set up git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
# cache: false # set to be true by default. Disable cache when debugging
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
cd others/script
go mod tidy
- name: Check and build
run: |
cd others/script
go run main.go --rime_path "${{ github.workspace }}" --auto_confirm
- name: Commit and push
run: |
git add --all
if ! git diff --cached --quiet; then
COMMIT_MSG=$(git log -1 --pretty=%B | sed -e 's/\s\[build\]$//' -e 's/^[a-zA-Z()]*:\s*//')
git commit -m "build(ci): auto build for -> ${COMMIT_MSG} <-"
git push
else
echo "No changes to commit."
fi

View File

@ -1,27 +1,41 @@
name: Pack and Release name: Build and Release
on: on:
push: push:
branches: branches:
- main - main
tags: tags:
- '[0-9]+.*' - "[0-9]+.*"
paths: paths:
- '**/**' - "**/**"
- '!**.md' - "!**.md"
- '!**.gitignore' - "!**.gitignore"
- '!others/**' - "!.github/**"
- '!.github/**'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
Release: Release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'iDvel/rime-ice'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Go
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Check and build
id: check_and_build
if: ${{ contains(github.event.head_commit.message, ' [build]') || github.event_name == 'workflow_dispatch' }}
run: |
cd others/script
go mod tidy
go run main.go --rime_path "${{ github.workspace }}" --auto_confirm
- name: Pack dicts - name: Pack dicts
run: | run: |
mkdir dist mkdir dist
@ -42,7 +56,7 @@ jobs:
- name: Create nightly release - name: Create nightly release
if: ${{ github.ref == 'refs/heads/main' }} if: ${{ github.ref == 'refs/heads/main' }}
uses: 'softprops/action-gh-release@v2' uses: "softprops/action-gh-release@v2"
with: with:
body: | body: |
## 说明 ## 说明
@ -65,10 +79,24 @@ jobs:
- name: Create stable release - name: Create stable release
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
uses: 'softprops/action-gh-release@v2' uses: "softprops/action-gh-release@v2"
with: with:
body_path: ${{ github.workspace }}/others/CHANGELOG.md body_path: ${{ github.workspace }}/others/CHANGELOG.md
draft: true draft: true
make_latest: true make_latest: true
files: | files: |
dist/* dist/*
- name: Push and commit
if: ${{ steps.check_and_build.outcome == 'success' }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add --all
if ! git diff --cached --quiet; then
COMMIT_MSG=$(git log -1 --pretty=%B | sed -e 's/\s\[build\]$//' -e 's/^[a-zA-Z()]*:\s*//')
git commit -m "build(ci): auto build for -> ${COMMIT_MSG} <-"
git push
else
echo "No changes to commit."
fi