Repository navigation
115 lines (115 loc) · 4.63 KB
/
Copy pathrelease.yml
File metadata and controls
115 lines (115 loc) · 4.63 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
name: Publish standalone release
# Tagging vX.Y.Z (without -alpha) publishes the official unsigned release assets.
# Never tag an unreviewed commit. Binaries are not code-signed.
# Never overwrite an existing release (including v2.3.0–v2.6.0). Ship fixes under a new tag.
# Release body MUST come from docs/releases/vX.Y.Z.md (version-specific), not the notes index.
# See docs/RELEASE-CHECKLIST.md and docs/GOVERNANCE.md.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
tag:
description: 'Release version to publish, e.g. v2.6.0 (must match model.go Version; leave empty only when unused)'
type: string
default: ''
required: true
permissions:
contents: read
jobs:
test:
name: Test on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest, macos-15-intel]
runs-on: ${{ matrix.os }}
steps:
# Tag push: github.ref is refs/tags/vX.Y.Z (commit = tagged SHA).
# workflow_dispatch: require inputs.tag to already exist and check it out so
# the built tree cannot silently diverge from the named release tag.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
fetch-depth: 0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.3'
cache: false
- run: go test ./...
- run: go vet ./...
- run: go run ./cmd/php2shell doctor
- name: Release documentation consistency
shell: bash
run: bash scripts/check-release-docs.sh
publish:
name: Build and publish release
needs: test
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
fetch-depth: 0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.3'
cache: false
- name: Build portable executables
run: bash scripts/build-release.sh
- name: Inspect assets
run: |
set -euo pipefail
./dist/php2shell-linux-amd64 version
file dist/php2shell-* | head -20
(cd dist && sha256sum --check --status SHA256SUMS)
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
set -euo pipefail
if [[ -z "${TAG}" ]]; then
echo "Refusing to publish: empty tag (set workflow_dispatch input or push a vX.Y.Z tag)" >&2
exit 1
fi
# Bind release to the checked-out commit (not the dispatch branch tip).
TARGET_SHA="$(git rev-parse HEAD)"
echo "Release target SHA: ${TARGET_SHA}"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag_sha="$(git rev-list -n 1 "$TAG")"
if [[ "$TARGET_SHA" != "$tag_sha" ]]; then
echo "Refusing to publish: checked-out HEAD $TARGET_SHA != tag $TAG at $tag_sha" >&2
exit 1
fi
fi
built="$(./dist/php2shell-linux-amd64 version | awk '{print $2}')"
if [[ "$TAG" != "v${built}" ]]; then
echo "Refusing to publish: tag $TAG does not match built version v${built}" >&2
exit 1
fi
if [[ "$TAG" == *-alpha.* || "$TAG" == *-beta.* || "$TAG" == *-rc.* ]]; then
echo "Refusing to publish prerelease tag $TAG via the official release workflow" >&2
exit 1
fi
bash scripts/check-release-docs.sh --for-tag "$TAG"
NOTES="docs/releases/${TAG}.md"
if [[ ! -f "$NOTES" ]]; then
echo "Refusing to publish: missing version-specific notes $NOTES" >&2
exit 1
fi
if grep -Eiq 'unreleased draft|do not tag or publish until' "$NOTES"; then
echo "Refusing to publish: $NOTES still contains draft/unreleased language" >&2
exit 1
fi
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists; do not silently overwrite assets" >&2
exit 1
fi
gh release create "$TAG" dist/php2shell-* dist/SHA256SUMS \
--target "${TARGET_SHA}" \
--title "PHP2Shell $TAG" \
--notes-file "$NOTES"