-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (62 loc) · 2.25 KB
/
Copy pathrelease.yml
File metadata and controls
72 lines (62 loc) · 2.25 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
# A release is a tag. Pushing v0.1.0 builds it, packages it and publishes it;
# nothing else does. An ordinary commit to master never ships anything.
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0 # git describe needs the history behind the tag
- name: Install SQLite
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
- name: Setup V
uses: vlang/setup-v@v1.7
# The tag is what people will quote in a bug report and v.mod is what
# 'gitlife version' prints. A release where they disagree is a release
# nobody can identify.
- name: Check the tag against v.mod
run: |
tag="${GITHUB_REF_NAME#v}"
version="${tag%%-*}" # a v0.1.0-rc1 dry run still tests 0.1.0
manifest=$(sed -n "s/^[[:space:]]*version:[[:space:]]*'\(.*\)'/\1/p" v.mod)
echo "tag ${GITHUB_REF_NAME}, version ${version}, v.mod ${manifest}"
test "${version}" = "${manifest}"
# The commit, not 'git describe': on a tagged commit describe answers with
# the tag, and 'gitlife v0.1.0 (v0.1.0)' tells nobody anything.
- name: Build
run: |
GITLIFE_COMMIT=$(git rev-parse --short HEAD) \
v -prod -o gitlife .
./gitlife version
- name: Package
run: |
name="gitlife-${GITHUB_REF_NAME}-linux-amd64"
mkdir "${name}"
cp gitlife README.md LICENSE "${name}/"
cp -r docs "${name}/"
tar czf "${name}.tar.gz" "${name}"
sha256sum "${name}.tar.gz" > "${name}.tar.gz.sha256"
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
run: |
# A tag carrying a suffix, v0.1.0-rc1, is a rehearsal and is published
# as one.
prerelease=""
case "${GITHUB_REF_NAME}" in
*-*) prerelease="--prerelease" ;;
esac
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--generate-notes \
${prerelease} \
gitlife-*.tar.gz gitlife-*.tar.gz.sha256