Skip to content

Build and Release Frontend #4

Build and Release Frontend

Build and Release Frontend #4

Workflow file for this run

name: Build and Release Frontend
on:
push:
tags:
- 'v*' # Trigger on version tags like v1.0.0
# allow manual runs from Actions UI
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. v1.2.3). If omitted, workflow will use current tag or release payload.'
required: false
# also allow triggering when a GitHub Release is published via the UI
release:
types:
- published
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Enable Corepack and pin Yarn
run: |
corepack enable
corepack prepare yarn@1.22.22 --activate
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/yarn
~/.npm
node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-deps-
- name: Build and Pack
run: |
chmod +x ./scripts/build.sh
./scripts/build.sh
- name: Set artifact names
id: set_names
run: |
version=$(node -e "try{console.log(require('./package.json').version||'')}catch(e){console.log('')}" ) || version=""
if [ -z "$version" ]; then
echo "ERROR: cannot read version from package.json" >&2
exit 1
fi
echo "ART_TAR=dreamview-frontend-${version}.tar.gz" >> $GITHUB_ENV
echo "ART_SHA=dreamview-frontend-${version}.tar.gz.sha256" >> $GITHUB_ENV
- name: Upload build artifact (tar)
uses: actions/upload-artifact@v4
with:
name: dreamview-frontend-tar
path: |
${{ env.ART_TAR }}
${{ env.ART_SHA }}
- name: Release
uses: softprops/action-gh-release@v1
with:
# prefer release payload tag, then tag ref, then manual input
tag_name: ${{ github.event.release.tag_name || github.ref_name || github.event.inputs.tag }}
name: ${{ github.event.release.tag_name || github.ref_name || github.event.inputs.tag }}
files: |
${{ env.ART_TAR }}
${{ env.ART_SHA }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
verify:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Enable Corepack and pin Yarn
run: |
corepack enable
corepack prepare yarn@1.22.22 --activate
- name: Restore artifact
uses: actions/download-artifact@v4
with:
name: dreamview-frontend-tar
path: ./artifact
- name: Unpack artifact
run: |
mkdir -p unpack
# Support both versioned and unversioned tarball names
tar -xzf artifact/*.tar.gz -C unpack
- name: Serve dist and smoke test
run: |
cd unpack/dist
nohup npx http-server -p 8081 -c-1 >/tmp/http-server.log 2>&1 &
sleep 2
curl -I http://localhost:8081 | head -n 5