-
Notifications
You must be signed in to change notification settings - Fork 1
197 lines (178 loc) · 6.85 KB
/
Copy pathcombined.yml
File metadata and controls
197 lines (178 loc) · 6.85 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: CombinedWorkflow
on:
schedule:
- cron: '0 */8 * * *'
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
sync_release:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- name: Get latest upstream release (non-prerelease)
id: upstream
uses: actions/github-script@v6
with:
script: |
const owner = 'OpenListTeam';
const repo = 'OpenList';
try {
const res = await github.rest.repos.getLatestRelease({ owner, repo });
core.setOutput('tag_name', res.data.tag_name || '');
core.setOutput('body', res.data.body || '');
core.setOutput('html_url', res.data.html_url || '');
} catch (err) {
if (err.status === 404) {
core.setOutput('not_found', 'true');
} else {
throw err;
}
}
- name: Abort if no upstream non-prerelease release found
if: steps.upstream.outputs.not_found == 'true'
run: |
echo "No upstream non-prerelease release found in OpenListTeam/OpenList. Exiting."
- name: Read and normalize versions
id: prep
run: |
raw_tag="${{ steps.upstream.outputs.tag_name }}"
echo "raw_tag=$raw_tag"
version="${raw_tag#v}"
version="${version#V}"
echo "version=$version" >> $GITHUB_OUTPUT
if [ -f "OpenList/qpkg.cfg" ]; then
cur=$(grep -E '^QPKG_VER' OpenList/qpkg.cfg | sed -E 's/.*=[[:space:]]*"?([^"]+)"?.*/\1/' || true)
echo "current=$cur" >> $GITHUB_OUTPUT
else
echo "current=" >> $GITHUB_OUTPUT
fi
- name: Exit if already up-to-date
if: steps.prep.outputs.version == steps.prep.outputs.current
run: |
echo "QPKG_VER already at ${{ steps.prep.outputs.version }} — nothing to do."
- name: Update OpenList/qpkg.cfg on master, commit and push
if: steps.prep.outputs.version != steps.prep.outputs.current
env:
NEW_VERSION: ${{ steps.prep.outputs.version }}
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [ -f "OpenList/qpkg.cfg" ]; then
sed -E -i 's/^(QPKG_VER[[:space:]]*=[[:space:]]*).*/\1"'"$NEW_VERSION"'"/' OpenList/qpkg.cfg || true
if ! grep -q '^QPKG_VER' OpenList/qpkg.cfg; then
echo "QPKG_VER=\"$NEW_VERSION\"" >> OpenList/qpkg.cfg
fi
else
mkdir -p OpenList
echo "QPKG_VER=\"$NEW_VERSION\"" > OpenList/qpkg.cfg
fi
git add OpenList/qpkg.cfg
if git diff --staged --quiet; then
echo "No changes to commit after editing OpenList/qpkg.cfg."
else
git commit -m "chore: bump QPKG_VER to ${NEW_VERSION} (sync OpenListTeam/OpenList)"
git push origin HEAD:master
fi
- name: Create tag v${{ steps.prep.outputs.version }} if missing
if: steps.prep.outputs.version != steps.prep.outputs.current
env:
NEW_VERSION: ${{ steps.prep.outputs.version }}
run: |
set -e
tag="v${NEW_VERSION}"
if git ls-remote --tags origin | grep -q "refs/tags/${tag}$"; then
echo "Tag ${tag} already exists; skipping tag creation."
else
git tag -a "${tag}" -m "${tag} (sync from OpenListTeam/OpenList)"
git push origin "refs/tags/${tag}"
fi
- name: Create or update GitHub release for v${{ steps.prep.outputs.version }}
if: steps.prep.outputs.version != steps.prep.outputs.current
uses: actions/github-script@v6
env:
VERSION: ${{ steps.prep.outputs.version }}
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const tag_name = `v${process.env.VERSION}`;
const upstream_url = `${{ steps.upstream.outputs.html_url }}`;
const upstream_body = `${{ steps.upstream.outputs.body }}`;
const body = `Sync from OpenListTeam/OpenList release ${tag_name}\n\nUpstream: ${upstream_url}\n\n${upstream_body}`;
try {
const existing = await github.rest.repos.getReleaseByTag({ owner, repo, tag: tag_name });
core.info(`Release for ${tag_name} already exists (id ${existing.data.id}), updating it.`);
await github.rest.repos.updateRelease({
owner,
repo,
release_id: existing.data.id,
tag_name,
name: tag_name,
body,
prerelease: false
});
} catch (err) {
if (err.status === 404) {
core.info(`Creating release ${tag_name}`);
await github.rest.repos.createRelease({
owner,
repo,
tag_name,
name: tag_name,
body,
prerelease: false
});
} else {
throw err;
}
}
- name: Install packages
if: steps.prep.outputs.version != steps.prep.outputs.current
run: |
sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
git-core \
ca-certificates \
wget \
python-is-python3 \
make \
gcc
# Runs a set of commands using the runners shell
- name: Setup QDK
if: steps.prep.outputs.version != steps.prep.outputs.current
run: |
git clone https://github.com/qnap-dev/QDK.git && \
cd QDK && sudo ./InstallToUbuntu.sh install
# Runs a set of commands using the runners shell
- name: Fetch OpenList
if: steps.prep.outputs.version != steps.prep.outputs.current
run: sh build/fetch.sh
# Runs a set of commands using the runners shell
- name: Build QNAP packages
if: steps.prep.outputs.version != steps.prep.outputs.current
run: sh build/build-qpkg.sh
# Runs a set of commands using the runners shell
- name: ls
if: steps.prep.outputs.version != steps.prep.outputs.current
run: ls -lrt
# - uses: actions/upload-artifact@v3
# with:
# name: my-artifact
# path: |
# *.qpkg
# *.md5
- name: Release
if: steps.prep.outputs.version != steps.prep.outputs.current
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.prep.outputs.version }}
files: |
*.qpkg
*.md5