-
Notifications
You must be signed in to change notification settings - Fork 4
170 lines (141 loc) · 4.27 KB
/
nightly.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Nightly Build
on:
schedule:
- cron: "0 10 * * *"
workflow_dispatch:
permissions:
contents: write
# packages: write
# issues: write
jobs:
check_need_build:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Need Build
id: check
run: |
if [[ "$(git log --since='24 hours ago' | wc -l)" -eq 0 ]] || \
[[ "$GITHUB_REPOSITORY" != "Redish101/reblog" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
test:
runs-on: ubuntu-latest
needs: check_need_build
if: ${{ needs.check_need_build.outputs.skip != 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9.7.0
- name: Install Dependencies
run: make install-dev
- name: Build
run: make
- name: Test
run: make test
build:
needs: [check_need_build, test]
if: ${{ needs.check_need_build.outputs.skip != 'true' }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [amd64, arm64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Turbo Build Setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9.7.0
- name: Install Dependencies
run: make install-dev
- name: Set GOARCH for AMD64
if: matrix.arch == 'amd64'
run: echo "GOARCH=amd64" >> $GITHUB_ENV
- name: Set GOARCH for ARM64
if: matrix.arch == 'arm64'
run: echo "GOARCH=arm64" >> $GITHUB_ENV
- name: Build
run: make VERSION=nightly
- name: Rename Binary
run: |
mv bin/reblog bin/reblog-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}
path: bin/reblog-${{ matrix.os }}-${{ matrix.arch }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/artifacts/
- name: Create tag and push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
gh release delete nightly --yes || true
git push origin :refs/tags/nightly || true
git tag -f nightly
git push -f origin nightly
- name: Generate Changelog
run: |
MD_FILE="/tmp/changelog.md"
echo -e "$CHANGELOG" > $MD_FILE
echo -e "\n> [!NOTE]\n" \
"> Nightly Build由ci在每晚自动从最新源代码构建并发布,仅作为预览使用,不保证可用性,不建议在生产环境下使用。" >> $MD_FILE
- name: Get Files
run: |
cd /tmp/artifacts
FILES=$(find ${DIST_DIR} -type f -exec readlink -f {} \;)
echo -e "RELEASE_FILES<<EOF" >> $GITHUB_ENV
echo -e "$FILES" >> $GITHUB_ENV
echo -e "EOF" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: true
tag_name: nightly
name: Nightly Build
body_path: /tmp/changelog.md
files: ${{ env.RELEASE_FILES }}
draft: false