Repository navigation
150 lines (134 loc) · 4.68 KB
/
Copy pathrelease.yml
File metadata and controls
150 lines (134 loc) · 4.68 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
name: Release
# Pushing a tag such as v0.1.0 tests the code, builds MaldocTrace for
# Windows, Linux and macOS, and publishes a GitHub Release with the archives,
# SHA-256 checksums, build provenance attestations and the matching
# CHANGELOG.md section as release notes. The same binaries are then wrapped
# in platform wheels and published to PyPI as the `maldoctrace` package
# (trusted publishing from the `pypi` environment; no token is stored).
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: go vet ./...
- run: go test ./...
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- { goos: windows, goarch: amd64 }
- { goos: windows, goarch: arm64 }
- { goos: linux, goarch: amd64 }
- { goos: linux, goarch: arm64 }
- { goos: darwin, goarch: amd64 }
- { goos: darwin, goarch: arm64 }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
VERSION="${GITHUB_REF_NAME#v}"
NAME="maldocTrace_${VERSION}_${GOOS}_${GOARCH}"
BIN="maldocTrace"
if [ "$GOOS" = "windows" ]; then BIN="maldocTrace.exe"; fi
mkdir -p "stage/$NAME" dist
go build -trimpath -ldflags "-s -w -X github.com/debugactiveprocess/MaldocTrace.Version=${VERSION}" -o "stage/$NAME/$BIN" ./cmd/maldoctrace
cp README.md CHANGELOG.md "stage/$NAME/"
cd stage
if [ "$GOOS" = "windows" ]; then
zip -qr "../dist/$NAME.zip" "$NAME"
else
tar -czf "../dist/$NAME.tar.gz" "$NAME"
fi
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Checksums
run: |
cd dist
sha256sum * > checksums.txt
cat checksums.txt
- name: Attest build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: dist/maldocTrace_*
- name: Release notes from CHANGELOG.md
run: |
VERSION="${GITHUB_REF_NAME#v}"
awk -v v="$VERSION" '
index($0, "## [" v "]") == 1 { found = 1; next }
found && index($0, "## [") == 1 { exit }
found { print }
' CHANGELOG.md > notes.md
if [ ! -s notes.md ]; then
echo "CHANGELOG.md has no section for [$VERSION]" >&2
exit 1
fi
cat notes.md
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" dist/* \
--repo "$GITHUB_REPOSITORY" \
--title "MaldocTrace $GITHUB_REF_NAME" \
--notes-file notes.md \
--verify-tag
pypi:
needs: release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/maldoctrace/
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Build wheels from the release binaries
run: |
VERSION="${GITHUB_REF_NAME#v}"
python3 python/build_wheels.py --version "$VERSION" --dist dist --out wheels
ls -l wheels
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
with:
packages-dir: wheels/