Skip to content

Commit bd73cc4

Browse files
Merge pull request #640 from nextcloud/backport/639/stable23
[stable23] Create appstore-build-publish.yml
2 parents 85f1d2c + afa3858 commit bd73cc4

File tree

2 files changed

+148
-2
lines changed

2 files changed

+148
-2
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
name: Build and publish app release
7+
8+
on:
9+
release:
10+
types: [published]
11+
12+
env:
13+
PHP_VERSION: 7.4
14+
15+
jobs:
16+
build_and_publish:
17+
runs-on: ubuntu-latest
18+
19+
# Only allowed to be run on nextcloud-releases repositories
20+
if: ${{ github.repository_owner == 'nextcloud-releases' }}
21+
22+
steps:
23+
- name: Check actor permission
24+
uses: skjnldsv/check-actor-permission@v2
25+
with:
26+
require: admin
27+
28+
- name: Set app env
29+
run: |
30+
# Split and keep last
31+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
32+
echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
33+
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
with:
37+
path: ${{ env.APP_NAME }}
38+
39+
- name: Get appinfo data
40+
id: appinfo
41+
uses: skjnldsv/xpath-action@master
42+
with:
43+
filename: ${{ env.APP_NAME }}/appinfo/info.xml
44+
expression: '//info//dependencies//nextcloud/@min-version'
45+
46+
- name: Read package.json node and npm engines version
47+
uses: skjnldsv/[email protected]
48+
id: versions
49+
# Continue if no package.json
50+
continue-on-error: true
51+
with:
52+
path: ${{ env.APP_NAME }}
53+
fallbackNode: '^12'
54+
fallbackNpm: '^6'
55+
56+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
57+
# Skip if no package.json
58+
if: ${{ steps.versions.outputs.nodeVersion }}
59+
uses: actions/setup-node@v2
60+
with:
61+
node-version: ${{ steps.versions.outputs.nodeVersion }}
62+
63+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
64+
# Skip if no package.json
65+
if: ${{ steps.versions.outputs.npmVersion }}
66+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
67+
68+
- name: Set up php ${{ env.PHP_VERSION }}
69+
uses: shivammathur/setup-php@v2
70+
with:
71+
php-version: ${{ env.PHP_VERSION }}
72+
coverage: none
73+
74+
- name: Check composer.json
75+
id: check_composer
76+
uses: andstor/file-existence-action@v1
77+
with:
78+
files: "${{ env.APP_NAME }}/composer.json"
79+
80+
- name: Install composer dependencies
81+
if: steps.check_composer.outputs.files_exists == 'true'
82+
run: |
83+
cd ${{ env.APP_NAME }}
84+
composer install --no-dev
85+
86+
- name: Build ${{ env.APP_NAME }}
87+
# Skip if no package.json
88+
if: ${{ steps.versions.outputs.nodeVersion }}
89+
run: |
90+
cd ${{ env.APP_NAME }}
91+
npm ci
92+
npm run build
93+
94+
- name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }}
95+
# Try krankerl, fallback to makefile
96+
run: |
97+
cd ${{ env.APP_NAME }}
98+
krankerl package || make appstore
99+
100+
- name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
101+
continue-on-error: true
102+
id: server-checkout
103+
run: |
104+
NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
105+
wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip
106+
unzip latest-$NCVERSION.zip
107+
108+
- name: Checkout server master fallback
109+
uses: actions/checkout@v2
110+
if: ${{ steps.server-checkout.outcome != 'success' }}
111+
with:
112+
repository: nextcloud/server
113+
path: nextcloud
114+
115+
- name: Sign app
116+
run: |
117+
# Extracting release
118+
cd ${{ env.APP_NAME }}/build/artifacts
119+
tar -xvf ${{ env.APP_NAME }}.tar.gz
120+
cd ../../../
121+
# Setting up keys
122+
echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key
123+
wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt"
124+
# Signing
125+
php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}
126+
# Rebuilding archive
127+
cd ${{ env.APP_NAME }}/build/artifacts
128+
tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
129+
130+
- name: Attach tarball to github release
131+
uses: svenstaro/upload-release-action@v2
132+
id: attach_to_release
133+
with:
134+
repo_token: ${{ secrets.GITHUB_TOKEN }}
135+
file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz
136+
asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz
137+
tag: ${{ github.ref }}
138+
overwrite: true
139+
140+
- name: Upload app to Nextcloud appstore
141+
uses: nextcloud-releases/nextcloud-appstore-push-action@v1
142+
with:
143+
app_name: ${{ env.APP_NAME }}
144+
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
145+
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
146+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ appstore:
7777
--certificate=$(cert_dir)/$(app_name).crt\
7878
--path=$(sign_dir)/$(app_name); \
7979
fi
80-
tar -czf $(build_dir)/$(app_name)-$(version).tar.gz \
80+
tar -czf $(build_dir)/$(app_name).tar.gz \
8181
-C $(sign_dir) $(app_name)
8282
@if [ -f $(cert_dir)/$(app_name).key ]; then \
8383
echo "Signing package…"; \
84-
openssl dgst -sha512 -sign $(cert_dir)/$(app_name).key $(build_dir)/$(app_name)-$(version).tar.gz | openssl base64; \
84+
openssl dgst -sha512 -sign $(cert_dir)/$(app_name).key $(build_dir)/$(app_name).tar.gz | openssl base64; \
8585
fi

0 commit comments

Comments
 (0)