Skip to content

Release v0.1.18

Release v0.1.18 #17

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: Existing git tag to release, for example v0.1.0
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE_MANIFEST_NAME: system.json
RELEASE_ZIP_NAME: yakov-dryh.zip
RELEASE_MANIFEST_URL: https://github.com/iosipov27/yakov-dryh/releases/latest/download/system.json
RELEASE_DOWNLOAD_URL: https://github.com/iosipov27/yakov-dryh/releases/latest/download/yakov-dryh.zip
steps:
- name: Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release tag
id: release
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
git checkout "$TAG"
else
TAG="${GITHUB_REF_NAME}"
fi
case "$TAG" in
v*)
;;
*)
echo "Expected a tag starting with v, got: $TAG" >&2
exit 1
;;
esac
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build runtime
run: npm run build
- name: Verify tag matches manifest version
env:
EXPECTED_VERSION: ${{ steps.release.outputs.version }}
run: |
node --input-type=module - <<'EOF'
import fs from "node:fs";
const manifest = JSON.parse(fs.readFileSync("system.json", "utf8"));
if (manifest.version !== process.env.EXPECTED_VERSION) {
throw new Error(`system.json version ${manifest.version} does not match tag version ${process.env.EXPECTED_VERSION}`);
}
EOF
- name: Package release assets
env:
MANIFEST_PATH: ${{ runner.temp }}/release/system.json
MANIFEST_URL: ${{ env.RELEASE_MANIFEST_URL }}
DOWNLOAD_URL: ${{ env.RELEASE_DOWNLOAD_URL }}
RELEASE_MANIFEST_PATH: ${{ runner.temp }}/system.json
RELEASE_ZIP_PATH: ${{ runner.temp }}/yakov-dryh.zip
run: |
PACKAGE_DIR="${RUNNER_TEMP}/release"
mkdir -p "$PACKAGE_DIR"
for path in assets lang packs scripts styles templates system.json README.md; do
if [ -e "$path" ]; then
cp -R "$path" "$PACKAGE_DIR/"
fi
done
node --input-type=module - <<'EOF'
import fs from "node:fs";
const manifest = JSON.parse(fs.readFileSync(process.env.MANIFEST_PATH, "utf8"));
manifest.manifest = process.env.MANIFEST_URL;
manifest.download = process.env.DOWNLOAD_URL;
fs.writeFileSync(process.env.MANIFEST_PATH, `${JSON.stringify(manifest, null, 2)}\n`);
EOF
cp "$PACKAGE_DIR/system.json" "$RELEASE_MANIFEST_PATH"
(
cd "$PACKAGE_DIR"
zip -r "$RELEASE_ZIP_PATH" .
)
- name: Verify package structure
env:
RELEASE_ZIP_PATH: ${{ runner.temp }}/yakov-dryh.zip
run: |
unzip -l "$RELEASE_ZIP_PATH"
unzip -l "$RELEASE_ZIP_PATH" system.json >/dev/null
unzip -l "$RELEASE_ZIP_PATH" scripts/main.js >/dev/null
unzip -l "$RELEASE_ZIP_PATH" styles/yakov-dryh.css >/dev/null
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release.outputs.tag }}
generate_release_notes: true
overwrite_files: true
files: |
${{ runner.temp }}/${{ env.RELEASE_MANIFEST_NAME }}
${{ runner.temp }}/${{ env.RELEASE_ZIP_NAME }}