-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (101 loc) · 3.46 KB
/
Copy pathrelease.yml
File metadata and controls
116 lines (101 loc) · 3.46 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
name: Release
on:
push:
tags:
- 'v*.*.*'
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
verify:
name: Verify release (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Check out release commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
- name: Install shell tooling (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y shellcheck shfmt zsh
- name: Install shell tooling (macOS)
if: runner.os == 'macOS'
run: brew install shellcheck shfmt
- name: Run verification suite
run: bash scripts/check.sh
publish:
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
attestations: write
id-token: write
artifact-metadata: write
steps:
- name: Check out release commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Require release commit on main
run: |
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
printf 'Release tag must point to a commit on main: %s\n' "$GITHUB_SHA" >&2
exit 1
fi
- name: Resolve release version
id: version
env:
PUSHED_TAG: ${{ github.ref_name }}
run: |
TAG="$PUSHED_TAG"
version="${TAG#v}"
source lib/common.sh
if ! selfishell_version_is_valid "$version"; then
printf 'Invalid release tag: %s\n' "$TAG" >&2
exit 1
fi
printf 'version=%s\n' "$version" >>"$GITHUB_OUTPUT"
printf 'tag=%s\n' "$TAG" >>"$GITHUB_OUTPUT"
- name: Build release artifacts
run: bash scripts/build-release.sh --version '${{ steps.version.outputs.version }}' --output dist
- name: Generate signed build provenance
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: dist/*
- name: Smoke test exact release
env:
SELFISHELL_BOOTSTRAP_OS: Linux
SELFISHELL_BOOTSTRAP_ARCH: x86_64
SELFISHELL_RELEASE_ROOT: file://${{ runner.temp }}/selfishell-releases
VERSION: ${{ steps.version.outputs.version }}
run: |
release_dir="$RUNNER_TEMP/selfishell-releases/download/v$VERSION"
mkdir -p "$release_dir"
cp dist/* "$release_dir/"
prefix="$RUNNER_TEMP/selfishell-prefix"
bash install.sh --version "$VERSION" --prefix "$prefix"
test "$("$prefix/bin/selfishell" version)" = "selfishell $VERSION"
- name: Publish immutable GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
release_args=()
[[ "$TAG" != *-* ]] || release_args+=(--prerelease)
gh release view "$TAG" >/dev/null 2>&1 && {
printf 'Release already exists: %s\n' "$TAG" >&2
exit 1
}
gh release create "$TAG" dist/* --verify-tag --generate-notes \
--title "$TAG" "${release_args[@]}"