All checks were successful
Build and publish webapp / build-and-publish (push) Successful in 1m4s
120 lines
3.4 KiB
YAML
120 lines
3.4 KiB
YAML
name: Build and publish webapp
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "gen*"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: publish-mui-${{ forgejo.ref_name }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: debian-latest
|
|
|
|
# PACKAGE_PUBLISH_TOKEN should be a personal access token belonging
|
|
# to the package owner, with package write/delete permissions.
|
|
env:
|
|
PACKAGE_OWNER: ${{ forgejo.repository_owner }}
|
|
PACKAGE_NAME: mui
|
|
PACKAGE_VERSION: ${{ forgejo.ref_name }}
|
|
FORGEJO_URL: ${{ forgejo.server_url }}
|
|
PACKAGE_TOKEN: ${{ secrets.PACKAGE_PUBLISH_TOKEN }}
|
|
|
|
steps:
|
|
- name: Check out repository and submodules
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Build application
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
npm install vite
|
|
cd shacl-vue
|
|
npm install
|
|
|
|
BUILD_GIT_COMMIT="$(git rev-parse HEAD)" \
|
|
BUILD_GIT_COMMIT_SHORT="$(git rev-parse --short HEAD)" \
|
|
BUILD_GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" \
|
|
BUILD_GIT_DATE="$(git show -s --format=%cI HEAD)" \
|
|
npm run build:app
|
|
|
|
- name: Require gen branch
|
|
shell: bash
|
|
run: |
|
|
if [[ "${FORGEJO_REF_NAME}" != gen* ]]; then
|
|
echo "Branch must start with 'gen': ${FORGEJO_REF_NAME}"
|
|
exit 1
|
|
fi
|
|
- name: Create tarball
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
PACKAGE_DIR="mui_${PACKAGE_VERSION}"
|
|
TARBALL="${PACKAGE_DIR}.tar.gz"
|
|
|
|
rm -rf package-staging "$TARBALL"
|
|
mkdir -p package-staging
|
|
mv shacl-vue/dist/app "package-staging/${PACKAGE_DIR}"
|
|
tar \
|
|
--create \
|
|
--gzip \
|
|
--file "$TARBALL" \
|
|
--directory package-staging \
|
|
"$PACKAGE_DIR"
|
|
tar -tzf "$TARBALL"
|
|
|
|
- name: Replace package version in Forgejo
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
REGISTRY_URL="${FORGEJO_URL}/api/packages/${PACKAGE_OWNER}/generic"
|
|
VERSION_URL="${REGISTRY_URL}/${PACKAGE_NAME}/${PACKAGE_VERSION}"
|
|
|
|
# a package version cannot be uploaded again until it is deleted.
|
|
# treat 404 as "nothing to delete".
|
|
status="$(
|
|
curl \
|
|
--silent \
|
|
--show-error \
|
|
--output /dev/null \
|
|
--write-out '%{http_code}' \
|
|
--user "${PACKAGE_OWNER}:${PACKAGE_TOKEN}" \
|
|
--request DELETE \
|
|
"$VERSION_URL"
|
|
)"
|
|
|
|
case "$status" in
|
|
204|404)
|
|
echo "Existing package version removed, or it did not exist."
|
|
;;
|
|
*)
|
|
echo "Failed to delete existing package version: HTTP $status"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
- name: Upload tarball
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
TARBALL="mui_${PACKAGE_VERSION}.tar.gz"
|
|
UPLOAD_URL="${FORGEJO_URL}/api/packages/${PACKAGE_OWNER}/generic/${PACKAGE_NAME}/${PACKAGE_VERSION}/${TARBALL}"
|
|
|
|
curl \
|
|
--fail-with-body \
|
|
--silent \
|
|
--show-error \
|
|
--user "${PACKAGE_OWNER}:${PACKAGE_TOKEN}" \
|
|
--upload-file "$TARBALL" \
|
|
"$UPLOAD_URL"
|
|
|