-
Notifications
You must be signed in to change notification settings - Fork 18
96 lines (81 loc) · 2.81 KB
/
release.yml
File metadata and controls
96 lines (81 loc) · 2.81 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
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: Release tag to publish, for example v0.1.0
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Build and publish release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- name: Resolve release version
id: version
run: |
set -eu
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="${{ inputs.tag }}"
else
tag="${GITHUB_REF_NAME}"
fi
if ! printf '%s\n' "$tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Release tag must look like vX.Y.Z, got: $tag" >&2
exit 1
fi
version="${tag#v}"
project_version="$(sed -n 's/^(version \([^)]*\)).*/\1/p' dune-project)"
if [ "$project_version" != "$version" ]; then
echo "Tag $tag does not match dune-project version $project_version" >&2
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libbpf-dev libelf-dev zlib1g-dev pkg-config
- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.2
- name: Install OCaml dependencies
run: opam install . --deps-only --with-test -y
- name: Build and test
run: |
opam exec -- dune build
opam exec -- dune runtest
- name: Build package archive
run: opam exec -- dune build @install
- name: Prepare release artifacts
run: |
set -eu
version="${{ steps.version.outputs.version }}"
staging="kernelscript-$version"
mkdir -p "dist/$staging"
git archive --format=tar --prefix="$staging/" HEAD | tar -x -C dist
cp _build/default/src/main.exe "dist/kernelscript-linux-x86_64"
tar -C dist -czf "dist/$staging-source.tar.gz" "$staging"
(cd dist && sha256sum "$staging-source.tar.gz" kernelscript-linux-x86_64 > "SHA256SUMS")
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${{ steps.version.outputs.tag }}"
version="${{ steps.version.outputs.version }}"
gh release create "$tag" \
--title "KernelScript $version" \
--generate-notes \
"dist/kernelscript-$version-source.tar.gz" \
"dist/kernelscript-linux-x86_64" \
"dist/SHA256SUMS"