Skip to content

chore(release): 0.0.2-alpha.33 #45

chore(release): 0.0.2-alpha.33

chore(release): 0.0.2-alpha.33 #45

Workflow file for this run

name: Create Release
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
channel:
description: 'alpha | beta | release'
required: false
type: choice
options: [alpha, beta, release]
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install tooling
run: sudo apt-get update && sudo apt-get install -y jq zip
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: npm ci
- name: "State"
run: |
echo "HEAD=$(git rev-parse --short HEAD)"
echo "MSG=$(git log -1 --pretty=%s)"
echo "PKG=$(node -p "require('./package.json').version")"
git tag --list | sort -V || true
- name: "Decide channel"
id: ch
run: |
IN="${{ github.event.inputs.channel }}"
CURR="$(node -p "require('./package.json').version")"
if [ -z "$IN" ]; then
if echo "$CURR" | grep -Eq -- '-alpha\.[0-9]+$'; then CH=alpha
elif echo "$CURR" | grep -Eq -- '-beta\.[0-9]+$'; then CH=beta
else CH=release
fi
else
CH="$IN"
fi
echo "channel=$CH" >> "$GITHUB_OUTPUT"
- name: "Determine bump type"
id: bump
run: |
TYPE="$(npx conventional-recommended-bump -p angular -r 0 || true)"
TYPE="$(echo "$TYPE" | tr -d '\r\n' | xargs)"
if [ -z "$TYPE" ]; then TYPE=patch; fi
echo "type=$TYPE" >> "$GITHUB_OUTPUT"
- name: "Compute next version"
id: ver
run: |
CH="${{ steps.ch.outputs.channel }}"
CURR="$(node -p "require('./package.json').version")"
BASE="${CURR%%-*}"
IFS='.' read -r MA MI PA <<< "$BASE"
case "${{ steps.bump.outputs.type }}" in
major) MA=$((MA+1)); MI=0; PA=0 ;;
minor) MI=$((MI+1)); PA=0 ;;
patch|*) PA=$((PA+1)) ;;
esac
NEXT_BASE="${MA}.${MI}.${PA}"
if [ "$CH" = "alpha" ] || [ "$CH" = "beta" ]; then
if echo "$CURR" | grep -Eq -- "-${CH}\.[0-9]+$"; then
BUILD="$(echo "$CURR" | sed -E 's/.*-'"$CH"'\.([0-9]+)$/\1/')"
BUILD=$((BUILD+1))
else
BUILD=0
fi
NEXT="${NEXT_BASE}-${CH}.${BUILD}"
else
NEXT="${NEXT_BASE}"
fi
echo "channel=$CH" >> "$GITHUB_OUTPUT"
echo "next_base=$NEXT_BASE" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
- name: "Version bump"
run: |
npx standard-version --release-as "${{ steps.ver.outputs.next }}"
git push --follow-tags origin HEAD:main
- name: "Read version"
id: v
run: echo "VERSION=$(node -p \"require('./package.json').version\")" >> "$GITHUB_OUTPUT"
- name: "Build manifests (latest + pinned)"
run: |
VERSION="${{ steps.v.outputs.VERSION }}"
REPO="https://github.com/${GITHUB_REPOSITORY}"
ZIP="sr3e-${VERSION}.zip"
MANIFEST_PINNED="${REPO}/releases/download/v${VERSION}/system.json"
MANIFEST_LATEST="${REPO}/releases/latest/download/system.json"
DOWNLOAD_URL="${REPO}/releases/download/v${VERSION}/${ZIP}"
jq --arg ver "$VERSION" --arg manifest "$MANIFEST_LATEST" --arg download "$DOWNLOAD_URL" \
'.version=$ver | .manifest=$manifest | .download=$download' system.json > system.latest.json
jq --arg ver "$VERSION" --arg manifest "$MANIFEST_PINNED" --arg download "$DOWNLOAD_URL" \
'.version=$ver | .manifest=$manifest | .download=$download' system.json > system.pinned.json
- name: Build
run: npm run build
- name: "Create package (players only)"
run: |
VERSION="${{ steps.v.outputs.VERSION }}"
ROOT="package/sr3e"
mkdir -p "$ROOT"
cp system.pinned.json "$ROOT/system.json"
cp -r build "$ROOT/"
cp -r lang "$ROOT/"
[ -d themes ] && cp -r themes "$ROOT/"
[ -d textures ] && cp -r textures "$ROOT/"
[ -d fonts ] && cp -r fonts "$ROOT/"
[ -d styles ] && cp -r styles "$ROOT/"
[ -d licences ] && cp -r licences "$ROOT/"
[ -d licenses ] && cp -r licenses "$ROOT/"
[ -f README.md ] && cp README.md "$ROOT/"
(cd package && zip -r "../sr3e-${VERSION}.zip" "sr3e")
cp system.latest.json system.json
- name: "Write release body + summary"
run: |
VERSION="${{ steps.v.outputs.VERSION }}"
{
echo "Install/Update manifest (latest channel): https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/system.json"
echo "Pinned manifest for this version: https://github.com/${GITHUB_REPOSITORY}/releases/download/v${VERSION}/system.json"
} > RELEASE_BODY.md
{
echo "### Release v${VERSION}"
echo "- Latest: https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/system.json"
echo "- Pinned: https://github.com/${GITHUB_REPOSITORY}/releases/download/v${VERSION}/system.json"
echo "- Zip: https://github.com/${GITHUB_REPOSITORY}/releases/download/v${VERSION}/sr3e-${VERSION}.zip"
echo "- Channel: ${{ steps.ver.outputs.channel }}"
} >> "$GITHUB_STEP_SUMMARY"
- name: "Create GitHub Release"
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.v.outputs.VERSION }}
name: v${{ steps.v.outputs.VERSION }}
body_path: RELEASE_BODY.md
files: |
sr3e-${{ steps.v.outputs.VERSION }}.zip
system.json
system.pinned.json
prerelease: ${{ steps.ch.outputs.channel != 'release' }}
make_latest: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}