Repository navigation
51 lines (46 loc) · 1.6 KB
/
Copy pathrelease.yml
File metadata and controls
51 lines (46 loc) · 1.6 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
name: Release
# Publishes a GitHub release for a version, with the matching section of
# CHANGELOG.md as notes and a zip of the site ready to host. Runs when a version
# tag is pushed, or by hand, in which case the tag is created on `target`.
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: Version tag (e.g. v0.2.0)
required: true
target:
description: Branch or full commit SHA to tag
required: true
default: main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract release notes
env:
TAG: ${{ inputs.tag || github.ref_name }}
run: |
awk -v version="${TAG#v}" '
/^## \[/ { if (found) exit; found = index($0, "[" version "]") > 0; next }
/^\[[^]]+\]: / { if (found) exit }
found
' CHANGELOG.md > notes.md
test -s notes.md || { echo "No CHANGELOG.md entry for $TAG" >&2; exit 1; }
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag || github.ref_name }}
TARGET: ${{ inputs.target || github.sha }}
run: |
commit=$(git rev-parse --verify "$TARGET^{commit}")
git archive --format=zip --prefix="sinklink-$TAG/" -o "sinklink-$TAG.zip" "$commit" \
index.html styles src assets LICENSE README.md
gh release create "$TAG" "sinklink-$TAG.zip" \
--target "$commit" --title "SinkLink $TAG" --notes-file notes.md