Fix yml syntax problem #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | ||
# SPDX-License-Identifier: AGPL-3.0 | ||
# | ||
# Author: Bernd rederlechner <[email protected] | ||
# | ||
# Assemble a customisation for recent trunk or a stable branch | ||
# If trunk, no backports are considered. For stable, only the | ||
# backports targetted for this baseline are considered. | ||
# | ||
# Assembly fails if a PR does not merge automatically. | ||
# | ||
name: MCLOUD build server (custom release) | ||
on: | ||
workflow_call: | ||
inputs: | ||
stable: | ||
description: The Nextcloud stable upstream branch of enterprise release | ||
required: true | ||
type: string | ||
assembly: | ||
description: name of the customisation branch holding the assembly | ||
required: true | ||
type: string | ||
tag: | ||
description: tag to use for the release (nmc<nc-version>-<custom-increment>) | ||
required: true | ||
type: string | ||
prerelease: | ||
description: mark the package as pre-release | ||
required: false | ||
type: string | ||
env: | ||
CUSTOM_SERVER_EXCLUDES: | | ||
/build/ | ||
/config/ | ||
/src/**/*.js | ||
/themes/example/ | ||
/vendor-bin/ | ||
/.devcontainer/ | ||
/.github/ | ||
/.idea/ | ||
/.tx/ | ||
/3rdparty/ | ||
/build/ | ||
/contribute/ | ||
/.* | ||
!/.gitignore | ||
!/.nextcloudignore | ||
/composer.* | ||
package.json | ||
package-lock.json | ||
webpack.* | ||
CUSTOM_TEST_EXCLUDES: | | ||
**/tests/ | ||
**/cypress/ | ||
/cypress*.ts | ||
/jest.config.ts | ||
jobs: | ||
build-custom: | ||
runs-on: ubuntu-latest | ||
env: | ||
BUILD_USER: ${{ github.actor }} | ||
BUILD_EMAIL: ${{ github.actor }}@users.noreply.github.com | ||
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN || secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Fetch custom assembly | ||
id: checkout_custom | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ github.repository }} | ||
ref: ${{ inputs.assembly }} | ||
fetch-depth: 1 | ||
token: ${{ env.BUILD_TOKEN }} | ||
- name: Fetch custom assembly | ||
id: checkout_stable | ||
run: | | ||
# set user in case commits are needed | ||
git config user.name $BUILD_USER | ||
git config user.email $BUILD_EMAIL | ||
# checkout stable as diff preparation | ||
git fetch origin ${{ inputs.stable }} | ||
git checkout ${{ inputs.stable }} | ||
# but dead-end origin to avoid unintended push | ||
git checkout ${{ inputs.assembly }} | ||
git remote set-url origin http://no.such.host | ||
### | ||
# To keep src as close as possible to Nextcloud checked in | ||
# artefacts (and reduce size of patch diffs), the default | ||
# release pack is created early | ||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ inputs.tag }} | ||
release_name: ${{ inputs.tag }}: MagentaCLOUD server customisation | ||
draft: false | ||
prerelease: ${{ inputs.prerelease || false }} | ||
# the node.js, npm install procedure is taken over from upstream Nextcloud | ||
# command-compile.yml | ||
- name: Detect NC compatible node.js,npm | ||
uses: skjnldsv/[email protected] | ||
id: package-engines-versions | ||
with: | ||
fallbackNode: '^16' | ||
fallbackNpm: '^7' | ||
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }} | ||
cache: npm | ||
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }} | ||
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}" | ||
- name: Install dependencies, build webpacks | ||
run: | | ||
npm ci | ||
npm run build --if-present | ||
# TODO: check whether we have to generate css from scss for server at all | ||
# TODO: check whether we have to generate icons (default.css) from scss for server at all | ||
# (could be only required for theme build) | ||
# either default ignores or listed in .nextcloudignore | ||
- name: Clean files | ||
env: | ||
CUSTOM_EXCLUDES: | | ||
${{ env.CUSTOM_SERVER_EXCLUDES }} | ||
${{ env.CUSTOM_TEST_EXCLUDES }} | ||
run: | | ||
echo -e "$CUSTOM_EXCLUDES" > ${RUNNER_TEMP}/.distignore | ||
set -x | ||
git ls-files -z --ignored --exclude-per-directory=${RUNNER_TEMP}/.distignore --cached | xargs -0 git rm -f | ||
set +x | ||
- name: Diff cleaned version | ||
run: | | ||
# locally add build changes, no push | ||
git add -A | ||
git commit -m "Temp add" | ||
git diff --patch --diff-filter=d --merge-base ${{ inputs.stable }} \ | ||
${{ inputs.assembly }} -- > ${RUNNER_TEMP}/custom-server.patch | ||
gzip -9 ${RUNNER_TEMP}/custom-server.patch | ||
# clean changes, just to avoid mess - but not absolutely necessary | ||
git reset HEAD~ | ||
- name: Upload server custom parts | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ env.BUILD_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ runner.temp }}/custom-server.patch.gz | ||
asset_name: custom-server.patch.gz | ||
asset_content_type: application/gzip | ||
- name: Post-failure cleanup | ||
id: release_cleanup | ||
if: ${{ !success() && steps.create_release.outcome == 'success' }} | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ env.BUILD_TOKEN }} | ||
script: | | ||
const releaseTag = "${{ inputs.tag }}"; | ||
// Get the release by tag | ||
const { data: release } = await github.rest.repos.getReleaseByTag({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag: releaseTag | ||
}); | ||
// Delete the release | ||
try { | ||
await github.rest.repos.deleteRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.id | ||
}); | ||
} catch (error) { | ||
// ignore on cleanup | ||
} | ||
// Delete the associated tag | ||
try { | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${releaseTag}` | ||
}); | ||
} catch (error) { | ||
// ignore on cleanup | ||
} | ||