Skip to content

Publish release

Publish release #248

Workflow file for this run

on:
release:
types: [published]
name: Publish release
jobs:
build:
name: Build, upload and release in the appstore
environment: release
env:
APP_ID: cospend
runs-on: ubuntu-latest
steps:
- name: Use Node 20
uses: actions/setup-node@v2
with:
node-version: 20
- name: Set up npm
run: npm i -g npm@^10.0.0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, intl, sqlite3
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
- name: Checkout code
uses: actions/checkout@v2
- name: Get current tag
id: tag
run: |
git fetch --tags --force
tag=$(git tag -l --points-at HEAD)
vtag=$(echo $tag | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+" || echo "")
echo "##[set-output name=currenttag;]$vtag"
- name: Build project
if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
id: build_release
run: |
echo "##[set-output name=app_id;]$APP_ID"
echo "###### copy app certificate"
mkdir -p ~/.nextcloud/certificates
wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${APP_ID}/${APP_ID}.crt" -O ~/.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 upgrade -y
sudo apt install make openssl -y
echo "###### installing nextcloud"
mkdir ~/html
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b master ~/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"
php ~/html/nextcloud/occ app:enable ${APP_ID}
php ~/html/nextcloud/occ maintenance:mode --off
cd ~/html/nextcloud/apps/${APP_ID}
echo "###### make appstore"
tag=${{ steps.tag.outputs.currenttag }}
version=${tag/v/}
webserveruser=runner occ_dir=~/html/nextcloud version=$version make build_release
echo "##[set-output name=version;]$version"
env:
APP_KEY: ${{ secrets.APP_KEY }}
- name: Attach tarball to github release
if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
uses: svenstaro/upload-release-action@2b9d2847a97b04d02ad5c3df2d3a27baa97ce689 # v2
id: attach_to_release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /tmp/build/${{ 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
tag: ${{ github.ref }}
overwrite: true
- name: Publish normal release to appstore
if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) && !endsWith( steps.tag.outputs.currenttag , 'nightly' ) }}
id: publish
run: |
SIGNATURE=$(cat /tmp/build/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 }}
- name: Publish nightly release to appstore
if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) && endsWith( steps.tag.outputs.currenttag , 'nightly' ) }}
id: nightly
run: |
SIGNATURE=$(cat /tmp/build/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}'", "nightly": true}'
env:
APPSTORE_TOKEN: ${{ secrets.APPSTORE_TOKEN }}