-
Notifications
You must be signed in to change notification settings - Fork 89
78 lines (72 loc) · 2.64 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: build
on:
push:
branches:
- master
paths:
- database/*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Download tool
run: ./scripts/init.sh
- name: Build
run: node --enable-source-maps tool create-release . ./publish
## prepare releases
- name: Commit release mirror
run: >
cd ./publish
&& (printf '${{ github.sha }}' > ./sha)
&& git init
&& git config user.email '66814738+ehtagtranslation[bot]@users.noreply.github.com'
&& git config user.name 'ehtagtranslation[bot]'
&& git add .
&& git commit -am 'Release for https://github.com/EhTagTranslation/Database/commit/${{ github.sha }}'
&& echo "MIRROR_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Set release note
run: node --enable-source-maps tool github-actions set-release-note --mirror-sha '${{ env.MIRROR_SHA }}'
# publish releases
- name: Create token
env:
APP_ID: ${{ secrets.APP_ID }}
APP_KEY: ${{ secrets.APP_KEY }}
APP_INSTALLATION_ID: ${{ secrets.APP_INSTALLATION_ID }}
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
APP_CLIENT_SECRET: ${{ secrets.APP_CLIENT_SECRET }}
run: node --enable-source-maps tool github-actions generate-token --env=APP_TOKEN
- name: Check latest
run: |
LATEST_SHA=$(git ls-remote origin master | cut -f1)
echo "Current commit: ${{ github.sha }}"
echo "Latest commit: $LATEST_SHA"
if [[ "$LATEST_SHA" != "${{ github.sha }}" ]]; then
echo "::warning::已经有新的版本提交,取消发布"
echo "SKIP=true" >> $GITHUB_ENV
fi
- name: Push release mirror
uses: ad-m/github-push-action@master
if: ${{ !env.SKIP }}
with:
github_token: ${{ env.APP_TOKEN }}
force: true
directory: ./publish
repository: EhTagTranslation/DatabaseReleases
- name: Upload release
uses: ncipollo/[email protected]
if: ${{ !env.SKIP }}
with:
artifacts: ./publish/*
name: ${{ env.RELEASE_NAME }}
body: ${{ env.RELEASE_BODY }}
token: ${{ env.APP_TOKEN }}
commit: ${{ github.sha }}
tag: ${{ format('v6.{0}.{1}', github.run_number, github.run_attempt) }}
- name: Clean releases
if: ${{ !env.SKIP }}
env:
GITHUB_TOKEN: ${{ env.APP_TOKEN }}
run: node --enable-source-maps tool github-actions delete-releases