Skip to content

Production Release

Production Release #11

Workflow file for this run

name: Production Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
jobs:
build:
name: Build, upload and release in the appstore
environment: release
env:
APP_ID: dicomviewer
runs-on: ubuntu-latest
steps:
- name: Use Node 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, sqlite3
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer, phpunit
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build project
id: build_release
run: |
echo "##[set-output name=app_id;]$APP_ID"
echo "###### copy app certificate"
mkdir -p ~/.nextcloud/certificates
echo "$APP_CRT" > ~/.nextcloud/certificates/${APP_ID}.crt
echo "$APP_KEY" > ~/.nextcloud/certificates/${APP_ID}.key
echo "###### install dependencies"
export DEBIAN_FRONTEND=noninteractive
sudo apt update -y
sudo apt install make openssl -y
echo "###### installing nextcloud"
mkdir ~/html
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b stable28 ~/html/nextcloud
sed -i $'s|if (substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|if (is_string($root) and substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|g' ~/html/nextcloud/lib/autoloader.php
cp -r $GITHUB_WORKSPACE ~/html/nextcloud/apps/${APP_ID}
php ~/html/nextcloud/occ maintenance:install --database "sqlite" --admin-user "admin" --admin-pass "password"
echo "###### make"
rm -rf ~/html/nextcloud/.eslintrc.js
cd ~/html/nextcloud/apps/${APP_ID}
webserveruser=runner occ_dir=~/html/nextcloud version=${version} make
php ~/html/nextcloud/occ app:enable ${APP_ID}
php ~/html/nextcloud/occ maintenance:mode --off
echo "###### make appstore"
cd ~/html/nextcloud/apps/${APP_ID}
version=${app_version}
tag=${version}
webserveruser=runner occ_dir=~/html/nextcloud version=${version} make appstore
build_dir=/tmp/build
sign_dir=/tmp/sign
echo "###### check code integrity"
php ~/html/nextcloud/occ integrity:check-app --path=${sign_dir}/${APP_ID}/ ${APP_ID}
echo "##[set-output name=version;]$version"
echo "##[set-output name=build_dir;]$build_dir"
echo "##[set-output name=sign_dir;]$sign_dir"
env:
app_version: ${{ github.event.inputs.version }}
APP_CRT: ${{ secrets.APP_CRT }}
APP_KEY: ${{ secrets.APP_KEY }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.build_release.outputs.version }}
release_name: ${{ steps.build_release.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build_release.outputs.build_dir }}/${{ steps.build_release.outputs.app_id }}-${{ steps.build_release.outputs.version }}.tar.gz
asset_name: ${{ steps.build_release.outputs.app_id }}-${{ steps.build_release.outputs.version }}.tar.gz
asset_content_type: application/gzip
- name: Publish production release to appstore
id: publish
run: |
appsigndir=${{ steps.build_release.outputs.sign_dir }}
SIGNATURE=$(cat ${appsigndir}/sign.txt | tr -d '\n')
VERSION=${{ steps.build_release.outputs.version }}
DOWNLOAD_URL=https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${APP_ID}-${VERSION}.tar.gz
curl -X POST -H "Authorization: Token $APPSTORE_TOKEN" https://apps.nextcloud.com/api/v1/apps/releases -H "Content-Type: application/json" -d '{"download":"'${DOWNLOAD_URL}'", "signature": "'${SIGNATURE}'"}'
env:
APPSTORE_TOKEN: ${{ secrets.APPSTORE_TOKEN }}