mirror of
https://github.com/OpenListTeam/OpenList-Frontend.git
synced 2026-03-13 11:20:24 +00:00
chore: update CI (#22)
* chore: update .gitignore * feat: cron task syncing backend i18n fuke * fix: should not include dist tarball * fix: update tag match rule for ci trigger * feat: allow manually trigger sync i18n files * fix: avoid hard coded repo name and push when PR * fix: specify frontend path (blocked by https://github.com/OpenListTeam/OpenList/pull/125) * refactor: ci refactor: pr build ci renamed refactor: release build ci renamed refactor: release build ci now accept pre-release tag refactor: pre-release build ci is now called rolling (will not be published to npm) refactor: tagging now will only trigger release build ci and will be published to npm * fix
This commit is contained in:
@@ -1,10 +1,27 @@
|
||||
# This workflow is used to create a (pre-)release build of the OpenList frontend.
|
||||
#
|
||||
# This will:
|
||||
#
|
||||
# - Update the `package.json` version to the specified version (when triggered
|
||||
# by `workflow_dispatch`), commit the changes and tag it.
|
||||
# - Upload the release assets to GitHub.
|
||||
# - Publish the package to npm.
|
||||
#
|
||||
# # Usage
|
||||
#
|
||||
# This workflow can be triggered by:
|
||||
#
|
||||
# - Pushing a tag that matches the pattern `v[0-9]+.[0-9]+.[0-9]+*` (semver format).
|
||||
# - Manually via the GitHub Actions UI with a version input.
|
||||
#
|
||||
# To create (pre-)release builds, we recommend that you use the `workflow_dispatch`.
|
||||
|
||||
name: Release Build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
- "!v*.*.*-*"
|
||||
- "v[0-9]+.[0-9]+.[0-9]+*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
@@ -54,8 +71,8 @@ jobs:
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
|
||||
git_user_signingkey: true
|
||||
git_commit_gpgsign: true
|
||||
git_tag_gpgsign: true
|
||||
@@ -115,18 +132,6 @@ jobs:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Publish npm
|
||||
run: |
|
||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
|
||||
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
|
||||
echo "NPM_TOKEN not set, do dry run"
|
||||
pnpm publish --dry-run --no-git-checks --access public
|
||||
else
|
||||
pnpm publish --no-git-checks --access public
|
||||
fi
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Upload Release Assets
|
||||
run: |
|
||||
# Delete local tag, or gh cli will complain about it.
|
||||
@@ -140,5 +145,26 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish npm
|
||||
run: |
|
||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
|
||||
# Delete the generated dist tarball
|
||||
rm -f dist/openlist-frontend-dist-v*.tar.gz
|
||||
|
||||
if ! jq -e '.name and .version' package.json > /dev/null; then
|
||||
echo "Error: Invalid package.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
|
||||
echo "NPM_TOKEN not set, performing dry run"
|
||||
pnpm publish --dry-run --no-git-checks --access public
|
||||
else
|
||||
echo "Publishing to npm..."
|
||||
pnpm publish --no-git-checks --access public
|
||||
fi
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -1,11 +1,17 @@
|
||||
name: Pre Release Build
|
||||
# This workflow builds a rolling version of the OpenList frontend and publishes it on GitHub.
|
||||
#
|
||||
# This will:
|
||||
#
|
||||
# - Upload the release assets to GitHub (always git tagged `rolling`).
|
||||
#
|
||||
# This workflow can be triggered on pushes to the `main` branch, or manually via the GitHub Actions UI.
|
||||
|
||||
name: Rolling Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*.*.*-*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
draft:
|
||||
@@ -15,8 +21,8 @@ on:
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
pre-release:
|
||||
name: Pre Release
|
||||
rolling:
|
||||
name: Rolling Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -48,14 +54,9 @@ jobs:
|
||||
- name: Read version and determine tag name
|
||||
id: version
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
version=$(cat dist/VERSION)
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=rolling" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
version=$(cat dist/VERSION)
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=rolling" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Remove the existing pre-release
|
||||
run: gh release delete ${{ steps.version.outputs.tag_name }} --cleanup-tag --yes || true
|
||||
@@ -68,7 +69,7 @@ jobs:
|
||||
--title "Pre-release ${{ steps.version.outputs.version }}" \
|
||||
--notes "Pre-release build for ${{ steps.version.outputs.version }}<br>This is a development build and not intended for production use." \
|
||||
--prerelease \
|
||||
--draft=${{ github.event_name == 'workflow_dispatch' && inputs.draft || false }} \
|
||||
--draft=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.draft || false }} \
|
||||
${{ steps.version.outputs.tag_name }} \
|
||||
dist/openlist-frontend-dist-v*-*.tar.gz
|
||||
env:
|
||||
39
.github/workflows/crowdin-upload.yml
vendored
39
.github/workflows/crowdin-upload.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: Crowdin Upload
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/lang/en/**"
|
||||
|
||||
jobs:
|
||||
crowdin-upload:
|
||||
name: Upload en lang source file to Crowdin
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Upload sources to Crowdin
|
||||
run: pnpm run crowdin:upload
|
||||
env:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
105
.github/workflows/i18n_sync.yml
vendored
Normal file
105
.github/workflows/i18n_sync.yml
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
name: Sync i18n files
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 12 * * *"
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/lang/en/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/i18n*.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync_i18n:
|
||||
name: Generate and i18n files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.21"
|
||||
|
||||
- name: Checkout frontend codes
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout backend codes
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ vars.SYNC_LANG_ENV_BACKEND_REPOSITORY || 'OpenListTeam/OpenList' }}
|
||||
path: backend
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Generate and update lang files
|
||||
run: |
|
||||
cd backend
|
||||
go run ./main.go lang --frontend-path ../
|
||||
cd ..
|
||||
|
||||
- name: Check for changes and stage
|
||||
id: verify-changed-files
|
||||
run: |
|
||||
cp -f ./backend/lang/*.json ./src/lang/en/ 2>/dev/null || :
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add src/lang/en/*.json
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Import GPG key
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
|
||||
git_config_global: true
|
||||
git_user_signingkey: true
|
||||
git_commit_gpgsign: true
|
||||
git_tag_gpgsign: true
|
||||
|
||||
- name: Setup CI Bot
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
run: |
|
||||
git config --global user.name "The OpenList Bot"
|
||||
git config --global user.email "bot@openlist.team"
|
||||
|
||||
- name: Commit the changes
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
run: |
|
||||
git commit -S -m "chore: auto update i18n file"
|
||||
# Skip pushing if triggered by a pull request
|
||||
if [ "${{ github.event_name }}" != "pull_request" ]; then
|
||||
git push
|
||||
fi
|
||||
|
||||
- name: Setup Node
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Install pnpm
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
# version: 9.9.0
|
||||
run_install: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Sync to Crowdin
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
run: |
|
||||
pnpm crowdin:upload
|
||||
env:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ dist
|
||||
!/src/lang/en/
|
||||
.DS_Store
|
||||
.idea
|
||||
.test
|
||||
Reference in New Issue
Block a user