-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (200 loc) · 8.53 KB
/
nightly-release.yml
File metadata and controls
239 lines (200 loc) · 8.53 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# SPDX-FileCopyrightText: 2026 LibreCode Coop and LibreCode contributors
#
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Nightly Release
on:
push:
branches:
- stable*
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/nightly-release.yml'
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
check-latest-stable:
runs-on: ubuntu-latest
outputs:
is_latest: ${{ steps.latest.outputs.is_latest }}
latest_branch: ${{ steps.latest.outputs.latest_branch }}
steps:
- name: Determine latest stable branch
id: latest
run: |
latest_number=$(git ls-remote --heads "https://github.com/${{ github.repository }}.git" 'stable*' | awk -F/ '{print $NF}' | sed 's/^stable//' | sort -n | tail -1)
if [ -z "$latest_number" ]; then
echo 'is_latest=false' >> "$GITHUB_OUTPUT"
exit 0
fi
latest_branch="stable${latest_number}"
echo "latest_branch=${latest_branch}" >> "$GITHUB_OUTPUT"
if [ "${GITHUB_REF_NAME}" = "${latest_branch}" ]; then
echo 'is_latest=true' >> "$GITHUB_OUTPUT"
else
echo 'is_latest=false' >> "$GITHUB_OUTPUT"
fi
nightly-release:
runs-on: ubuntu-latest
needs: check-latest-stable
if: needs.check-latest-stable.outputs.is_latest == 'true'
env:
APP_NAME: profile_fields
steps:
- name: Check actor permission
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
with:
require: write
- name: Validate app name
run: |
[ "${GITHUB_REPOSITORY##*/}" = "${APP_NAME}" ]
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: true
submodules: true
path: ${{ env.APP_NAME }}
- name: Validate signing secret
env:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
run: |
test -n "${APP_PRIVATE_KEY}"
- name: Get app version number
id: app-version
uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0
with:
filename: ${{ env.APP_NAME }}/appinfo/info.xml
expression: "//info//version/text()"
- name: Set APP_VERSION env
run: |
echo "APP_VERSION=${{ fromJSON(steps.app-version.outputs.result).version }}" >> "$GITHUB_ENV"
- name: Get appinfo data
id: appinfo
uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0
with:
filename: ${{ env.APP_NAME }}/appinfo/info.xml
expression: "//info//dependencies//nextcloud/@min-version"
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
continue-on-error: true
with:
path: ${{ env.APP_NAME }}
fallbackNode: '^24'
fallbackNpm: '^11.3'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
if: ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
if: ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
- name: Get php version
id: php-versions
uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
with:
filename: ${{ env.APP_NAME }}/appinfo/info.xml
- name: Set up php ${{ steps.php-versions.outputs.php-min }}
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0
with:
php-version: ${{ steps.php-versions.outputs.php-min }}
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check server download link for ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
id: server-url
run: |
NCVERSION='${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}'
DOWNLOAD_URL=$(curl -s "https://updates.nextcloud.com/updater_server/latest?channel=beta&version=$NCVERSION" | jq -r '.downloads.zip[0]')
echo "url=$DOWNLOAD_URL" >> "$GITHUB_OUTPUT"
- name: Download server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
continue-on-error: true
id: server-download
if: steps.server-url.outputs.url != 'null'
run: |
wget "${{ steps.server-url.outputs.url }}" -O nextcloud.zip
unzip nextcloud.zip
- name: Checkout server master fallback
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: ${{ steps.server-download.outcome != 'success' }}
with:
persist-credentials: false
submodules: true
repository: nextcloud/server
path: nextcloud
- name: Package ${{ env.APP_NAME }} nightly with makefile
run: |
cd "${{ env.APP_NAME }}"
mkdir -p build/tools/certificates/
printf '%s' '${{ secrets.APP_PRIVATE_KEY }}' > "build/tools/certificates/${{ env.APP_NAME }}.key"
chmod 600 "build/tools/certificates/${{ env.APP_NAME }}.key"
make appstore verify-appstore-package
- name: Define nightly metadata
id: version
run: |
echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
echo 'tag=nightly' >> "$GITHUB_OUTPUT"
echo "branch=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
- name: Update nightly tag
run: |
cd "${{ env.APP_NAME }}"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
TAG='${{ steps.version.outputs.tag }}'
git tag -f "$TAG" "${GITHUB_SHA}"
git push -f origin "$TAG"
- name: Get recent commits for release notes
run: |
cd "${{ env.APP_NAME }}"
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | grep -v nightly || echo '')
if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log -10 --pretty=format:'- %s (%h)' --no-merges)
else
COMMITS=$(git log "${LAST_TAG}"..HEAD --pretty=format:'- %s (%h)' --no-merges)
fi
cat <<EOF > release-notes.md
Nightly build for version ${{ steps.version.outputs.version }} from branch ${{ steps.version.outputs.branch }}.
Development build. It may contain unstable changes.
Recent changes:
$COMMITS
EOF
- name: Create or update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG='${{ steps.version.outputs.tag }}'
TITLE="Nightly ${{ steps.version.outputs.version }} (${{ steps.version.outputs.branch }})"
NOTES_FILE='${{ env.APP_NAME }}/release-notes.md'
if gh release view "$TAG" --repo '${{ github.repository }}' > /dev/null 2>&1; then
gh release edit "$TAG" \
--repo '${{ github.repository }}' \
--title "$TITLE" \
--notes-file "$NOTES_FILE" \
--prerelease
else
gh release create "$TAG" \
--repo '${{ github.repository }}' \
--title "$TITLE" \
--notes-file "$NOTES_FILE" \
--prerelease
fi
- name: Attach tarball to GitHub release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2.11.5
id: attach_to_release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz
asset_name: ${{ env.APP_NAME }}-${{ steps.version.outputs.tag }}.tar.gz
tag: ${{ steps.version.outputs.tag }}
overwrite: true
- name: Upload app to Nextcloud appstore (nightly)
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1
with:
app_name: ${{ env.APP_NAME }}
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
nightly: true