-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (74 loc) · 2.85 KB
/
github-release.yml
File metadata and controls
83 lines (74 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: GitHub Release
on:
push:
tags:
- v*.*.*
permissions:
contents: write
jobs:
publish_release:
runs-on: ubuntu-latest
name: Publish GitHub release package
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build production site
run: npm run build
- name: Resolve release metadata
id: release_meta
shell: bash
run: |
set -euo pipefail
TAG_NAME="${GITHUB_REF_NAME}"
RELEASE_DIR=".documentation/releases/${TAG_NAME}"
RELEASE_NOTES="${RELEASE_DIR}/release-notes.md"
if [ ! -d "${RELEASE_DIR}" ]; then
echo "Expected release directory ${RELEASE_DIR} was not found. Run /devspark.release and commit the generated release docs before pushing tag ${TAG_NAME}." >&2
exit 1
fi
if [ ! -f "${RELEASE_NOTES}" ]; then
echo "Expected release notes file ${RELEASE_NOTES} was not found." >&2
exit 1
fi
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "release_dir=${RELEASE_DIR}" >> "$GITHUB_OUTPUT"
echo "release_notes=${RELEASE_NOTES}" >> "$GITHUB_OUTPUT"
- name: Build release bundle
shell: bash
run: |
set -euo pipefail
TAG_NAME="${{ steps.release_meta.outputs.tag_name }}"
RELEASE_DIR="${{ steps.release_meta.outputs.release_dir }}"
BUNDLE_ROOT="release-package/${TAG_NAME}"
mkdir -p "${BUNDLE_ROOT}/site"
mkdir -p "${BUNDLE_ROOT}/release-docs"
cp -R docs/. "${BUNDLE_ROOT}/site/"
cp -R "${RELEASE_DIR}/." "${BUNDLE_ROOT}/release-docs/"
cp CHANGELOG.md "${BUNDLE_ROOT}/CHANGELOG.md"
if [ -f ".documentation/CHANGELOG.md" ]; then
cp ".documentation/CHANGELOG.md" "${BUNDLE_ROOT}/documentation-CHANGELOG.md"
fi
if [ -f "staticwebapp.config.json" ]; then
cp "staticwebapp.config.json" "${BUNDLE_ROOT}/staticwebapp.config.json"
fi
cd release-package
zip -r "${TAG_NAME}-bundle.zip" "${TAG_NAME}"
sha256sum "${TAG_NAME}-bundle.zip" > "${TAG_NAME}-bundle.sha256"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_meta.outputs.tag_name }}
name: ${{ steps.release_meta.outputs.tag_name }}
body_path: ${{ steps.release_meta.outputs.release_notes }}
files: |
release-package/${{ steps.release_meta.outputs.tag_name }}-bundle.zip
release-package/${{ steps.release_meta.outputs.tag_name }}-bundle.sha256