Repository navigation
165 lines (152 loc) · 6 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (152 loc) · 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# SPDX-License-Identifier: LGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 mplx <mplx@jennifer-lang.dev>
#
# Cut a GitHub release when a stable version tag is pushed.
#
# A deck has nothing to compile and no per-platform artifact: it is Jennifer
# source, consumed by vendoring src/ into a project. So the release is the tag
# plus the archive jvc would fetch, and the gate in front of it is test.yml
# itself, called rather than copied - a red suite must not become a tag.
#
# Release tags are stable semver only, without a prefix: `0.2.0`, never
# `v0.2.0`. Neither a `v` tag nor a prerelease tag (`0.2.0-rc1`) is a release:
# the trigger does not match them, and the gate below refuses one that slips
# through or a manual run from a branch.
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
permissions:
contents: read
jobs:
tag:
name: Check the tag
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v7
# The trigger glob is loose; this is the gate. workflow_dispatch from a
# branch lands here too and fails, which is the intent.
- name: Tag must be a stable release
run: |
set -euo pipefail
if [[ ! "${GITHUB_REF_NAME}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::${GITHUB_REF_NAME} is not a stable release tag (N.N.N, no v prefix)"
exit 1
fi
# The manifest version is what jvc resolves against, read from the
# default branch, so a tag that disagrees with it would publish the deck
# under a number nothing else knows about.
- name: Tag must match the manifest
run: |
set -euo pipefail
source tools/deck-lib.sh && deck_load
if [[ "${GITHUB_REF_NAME}" != "$DECK_VERSION" ]]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match ${DECK_MANIFEST} version ${DECK_VERSION}"
echo "::error::bump the manifest and commit it before tagging"
exit 1
fi
echo "${DECK_MANIFEST} declares ${DECK_VERSION}, matching the tag"
- name: The deck must have been initialised
run: tools/check-identity.sh --release
test:
name: The gate
needs: tag
uses: ./.github/workflows/test.yml
# Publishing targets GitHub (releases, Pages). The repositories are also on
# the project's Forgejo, whose runner executes these workflows too: there the
# tag is still checked and the gate still runs, but nothing is published.
release:
name: Create the release
needs: test
if: github.server_url == 'https://github.com'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out
uses: actions/checkout@v7
with:
# Tags for the version, and history for the notes.
fetch-depth: 0
# A deck with a generated version file ships it stamped with the tag.
- name: Build the release archive
id: pack
run: |
set -euo pipefail
tools/inject-version.sh
source tools/deck-lib.sh && deck_load
tools/pack.sh dist
{
echo "name=${DECK_NAME}"
echo "slug=${DECK_SLUG}"
echo "scope=${DECK_SCOPE}"
echo "version=${DECK_VERSION}"
echo "root=${DECK_SCOPE}-${DECK_SLUG}-${DECK_VERSION}"
echo "manual=$(deck_field package.urls.manual)"
echo "description=$(deck_field package.description)"
} >> "$GITHUB_OUTPUT"
- name: Write the release notes
env:
SLUG: ${{ steps.pack.outputs.slug }}
SCOPE: ${{ steps.pack.outputs.scope }}
ROOT: ${{ steps.pack.outputs.root }}
MANUAL: ${{ steps.pack.outputs.manual }}
DESCRIPTION: ${{ steps.pack.outputs.description }}
NAME: ${{ steps.pack.outputs.name }}
run: |
set -euo pipefail
{
echo "${DESCRIPTION}"
echo
echo "**Documentation:** ${MANUAL}"
echo
echo "**Install** - \`jvc add ${NAME}\`, or vendor the \`src/\` subtree by hand:"
echo
echo '```sh'
echo "mkdir -p vendor/${SCOPE}/${SLUG}"
echo "tar -xzf ${ROOT}.tar.gz -C vendor/${SCOPE}/${SLUG} \\"
echo " --strip-components=2 ${ROOT}/src"
echo '```'
echo
echo "## Changes"
echo
} > notes.md
previous="$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || true)"
if [[ -n "$previous" ]]; then
git log --no-merges --pretty='- %s' "${previous}..${GITHUB_REF_NAME}" >> notes.md
else
echo "- first release" >> notes.md
fi
cat notes.md
- name: Create the release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh release create "${GITHUB_REF_NAME}" \
--title "${{ steps.pack.outputs.slug }} ${{ steps.pack.outputs.version }}" \
--notes-file notes.md \
dist/*.tar.gz dist/*.tar.gz.sha256 dist/*.tar.gz.checksum
# Publish the book once the release exists: docs.yml on the default branch
# builds the highest release tag, this one. One path for every release,
# whatever order main and the tag were pushed in. (forensicgenetics 0.4.0,
# 2026-11-06: two tag-triggered deploys reported success and the site kept
# the previous build; a default-branch run replaced it. Cause unknown.)
# workflow_dispatch is one of the two events the GITHUB_TOKEN may start
# another workflow with.
docs:
name: Publish the documentation
needs: release
if: github.server_url == 'https://github.com'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Run docs.yml on the default branch
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ github.event.repository.default_branch }}
run: gh workflow run docs.yml --repo "${GITHUB_REPOSITORY}" --ref "${BRANCH}"