Skip to content

Commit d409587

Browse files
authored
Create appstore-build-publish.yml
1 parent c953c48 commit d409587

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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: write
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@v3
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/read-package-engines-version-actions@v1.2
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@v3
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: Check Krankerl config
95+
id: krankerl
96+
uses: andstor/file-existence-action@v1
97+
with:
98+
files: ${{ env.APP_NAME }}/krankerl.toml
99+
100+
- name: Install Krankerl
101+
if: steps.krankerl.outputs.files_exists == 'true'
102+
run: |
103+
wget https://github.com/ChristophWurst/krankerl/releases/download/v0.13.0/krankerl_0.13.0_amd64.deb
104+
sudo dpkg -i krankerl_0.13.0_amd64.deb
105+
106+
- name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl
107+
if: steps.krankerl.outputs.files_exists == 'true'
108+
run: |
109+
cd ${{ env.APP_NAME }}
110+
krankerl package
111+
112+
- name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile
113+
if: steps.krankerl.outputs.files_exists != 'true'
114+
run: |
115+
cd ${{ env.APP_NAME }}
116+
make appstore
117+
118+
- name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
119+
continue-on-error: true
120+
id: server-checkout
121+
run: |
122+
NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
123+
wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip
124+
unzip latest-$NCVERSION.zip
125+
126+
- name: Checkout server master fallback
127+
uses: actions/checkout@v3
128+
if: ${{ steps.server-checkout.outcome != 'success' }}
129+
with:
130+
repository: nextcloud/server
131+
path: nextcloud
132+
133+
- name: Sign app
134+
run: |
135+
# Extracting release
136+
cd ${{ env.APP_NAME }}/build/artifacts
137+
tar -xvf ${{ env.APP_NAME }}.tar.gz
138+
cd ../../../
139+
# Setting up keys
140+
echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key
141+
wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt"
142+
# Signing
143+
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 }}
144+
# Rebuilding archive
145+
cd ${{ env.APP_NAME }}/build/artifacts
146+
tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
147+
148+
- name: Attach tarball to github release
149+
uses: svenstaro/upload-release-action@v2
150+
id: attach_to_release
151+
with:
152+
repo_token: ${{ secrets.GITHUB_TOKEN }}
153+
file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz
154+
asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz
155+
tag: ${{ github.ref }}
156+
overwrite: true
157+
158+
- name: Upload app to Nextcloud appstore
159+
uses: nextcloud-releases/nextcloud-appstore-push-action@v1
160+
with:
161+
app_name: ${{ env.APP_NAME }}
162+
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
163+
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
164+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

0 commit comments

Comments
 (0)