Skip to content

Commit 52ffe27

Browse files
authoredNov 27, 2024··
Merge pull request #4226 from nextcloud/ci/release-automation
ci: Add release automation
2 parents 7efe584 + 071196b commit 52ffe27

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Build and publish app release conventionally
10+
11+
on:
12+
workflow_dispatch:
13+
branches: stable*
14+
15+
env:
16+
PHP_VERSION: 8.2
17+
18+
jobs:
19+
build_and_publish:
20+
runs-on: [ubuntu-latest, self-hosted]
21+
environment: release
22+
23+
steps:
24+
- name: Check actor permission
25+
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
26+
with:
27+
require: write
28+
29+
- name: Set app env
30+
run: |
31+
# Split and keep last
32+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
33+
34+
- name: Checkout
35+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
36+
with:
37+
token: ${{ secrets.RELEASE_PAT }}
38+
fetch-depth: 0
39+
40+
- name: Conventional Changelog Action
41+
id: changelog
42+
uses: TriPSs/conventional-changelog-action@v3
43+
with:
44+
github-token: ${{ secrets.RELEASE_PAT }}
45+
git-user-email: nextcloud-command@users.noreply.github.com
46+
git-user-name: Nextcloud Command Bot
47+
skip-git-pull: "true"
48+
pre-commit: build/pre-commit.js
49+
release-count: 0
50+
version-file: "package.json, package-lock.json"
51+
52+
- name: Get appinfo data
53+
id: appinfo
54+
uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master
55+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
56+
with:
57+
filename: appinfo/info.xml
58+
expression: "//info//dependencies//nextcloud/@min-version"
59+
60+
- name: Read package.json node and npm engines version
61+
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
62+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
63+
id: versions
64+
# Continue if no package.json
65+
continue-on-error: true
66+
with:
67+
path: ./
68+
fallbackNode: '^20'
69+
fallbackNpm: '^9'
70+
71+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
72+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
73+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
74+
with:
75+
node-version: ${{ steps.versions.outputs.nodeVersion }}
76+
77+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
78+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
79+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
80+
81+
- name: Set up php ${{ env.PHP_VERSION }}
82+
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2
83+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
84+
with:
85+
php-version: ${{ env.PHP_VERSION }}
86+
coverage: none
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Install Krankerl
91+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
92+
run: |
93+
wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb
94+
sudo dpkg -i krankerl_0.14.0_amd64.deb
95+
96+
- name: Package ${{ env.APP_NAME }} ${{ steps.changelog.outputs.tag }} with krankerl
97+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
98+
run: krankerl package
99+
100+
- name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
101+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
102+
continue-on-error: true
103+
id: server-checkout
104+
run: |
105+
NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
106+
wget https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip -o build/nextcloud.zip
107+
unzip build/nextcloud.zip build/nextcloud
108+
109+
- name: Checkout server master fallback
110+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
111+
if: ${{ steps.changelog.outputs.skipped == 'false' && steps.server-checkout.outcome != 'success' }}
112+
with:
113+
submodules: true
114+
repository: nextcloud/server
115+
path: build/nextcloud
116+
117+
- name: Sign app
118+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
119+
run: |
120+
# Extracting release
121+
cd build/artifacts
122+
tar -xvf ${{ env.APP_NAME }}.tar.gz
123+
cd ../../
124+
# Setting up keys
125+
echo "${{ secrets.APP_CERT }}" > build/${{ env.APP_NAME }}.crt
126+
echo "${{ secrets.APP_PRIVATE_KEY }}" > build/${{ env.APP_NAME }}.key
127+
pwd
128+
ls -l
129+
ls -l build
130+
# Signing
131+
php build/nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../artifacts/${{ env.APP_NAME }}
132+
# Rebuilding archive
133+
cd build/artifacts
134+
tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
135+
136+
- name: Push tag to releases organization
137+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
138+
run: |
139+
git remote add release https://github.com/nextcloud-releases/${{ env.APP_NAME }}.git
140+
git push release ${{ steps.changelog.outputs.tag }}
141+
142+
- name: Attach tarball to github release
143+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
144+
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2
145+
id: attach_to_release
146+
with:
147+
repo_token: ${{ secrets.RELEASE_PAT }}
148+
repo_name: nextcloud-releases/${{ env.APP_NAME }}
149+
file: build/artifacts/${{ env.APP_NAME }}.tar.gz
150+
asset_name: ${{ env.APP_NAME }}-${{ steps.changelog.outputs.tag }}.tar.gz
151+
tag: ${{ steps.changelog.outputs.tag }}
152+
overwrite: true
153+
154+
- name: Upload app to Nextcloud appstore
155+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
156+
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1
157+
with:
158+
app_name: ${{ env.APP_NAME }}
159+
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
160+
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
161+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

0 commit comments

Comments
 (0)
Please sign in to comment.