-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (100 loc) · 4 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (100 loc) · 4 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
name: Release
# Publishes a release the installer can actually verify.
#
# The previous flow produced a tarball with no checksum, and install.sh
# downloaded whatever "latest" resolved to and `sudo mv`d it into
# /usr/local/bin unverified. This publishes SHA256SUMS alongside the binary,
# and attaches the third-party notices as their own asset so they can be read
# without running the binary.
on:
push:
tags:
- "ai-studio-cli-*-opensource" # e.g. ai-studio-cli-1.2.0-1-opensource
workflow_dispatch:
inputs:
tag:
description: "Annotated tag to build and release (must already exist)"
required: true
permissions:
contents: write
env:
GO_VERSION: "1.25"
BINARY: ai-studio-cli
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
# Annotated tag metadata is needed to verify the tag is not
# lightweight — see the check below.
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: ai-studio-cli/go.sum
- name: Tag must be annotated
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-$GITHUB_REF_NAME}"
type=$(git cat-file -t "$TAG" 2>/dev/null || echo missing)
if [ "$type" != "tag" ]; then
echo "::error::'$TAG' is a lightweight tag (type=$type)."
echo "Lightweight tags carry no author, date or signature, and can be"
echo "silently repointed. Re-cut it with: git tag -a -s $TAG -m ..."
exit 1
fi
echo "$TAG is annotated."
- name: Compliance gate
run: make compliance
- name: Build with generated notices
# This is where the placeholder is a hard stop rather than a note.
# `build-release` generates the notices, builds, and fails if the
# resulting binary cannot print them. A released binary must never ship
# without its attribution.
run: make build-release
- name: Verify the binary carries its notices
run: |
out=$(./bin/${BINARY} licenses)
# if/then, not `grep -q ... && { exit 1; }`. The AND-list returns
# grep's status, so in the good case (marker absent) it evaluates to 1
# — and if it were ever the last command in the step, `bash -e` would
# fail the step precisely when nothing was wrong.
if grep -q "NOTICES-NOT-GENERATED" <<<"$out"; then
echo "::error::refusing to release a binary embedding the placeholder."
exit 1
fi
echo "Notices embedded: $(grep -ci copyright <<<"$out") copyright lines."
- name: Package
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-$GITHUB_REF_NAME}"
mkdir -p dist
# The tarball carries the notices and licence beside the binary, so
# they are present even for someone who never runs `licenses`.
cp LICENSE NOTICE ai-studio-cli/internal/notices/THIRD-PARTY-NOTICES.txt dist/
cp "bin/${BINARY}" dist/
tar -czf "${TAG}.tar.gz" -C dist .
cp ai-studio-cli/internal/notices/THIRD-PARTY-NOTICES.txt .
- name: Checksums
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-$GITHUB_REF_NAME}"
sha256sum "${TAG}.tar.gz" THIRD-PARTY-NOTICES.txt > SHA256SUMS
cat SHA256SUMS
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-$GITHUB_REF_NAME}"
gh release create "$TAG" \
--title "ai-studio-cli $TAG" \
--generate-notes \
--verify-tag \
"${TAG}.tar.gz" \
THIRD-PARTY-NOTICES.txt \
SHA256SUMS \
|| gh release upload "$TAG" \
"${TAG}.tar.gz" THIRD-PARTY-NOTICES.txt SHA256SUMS --clobber