-
Notifications
You must be signed in to change notification settings - Fork 52
162 lines (136 loc) · 4.75 KB
/
ci.yaml
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
151
152
153
154
155
156
157
158
159
160
161
162
name: For each PR and Push
on:
pull_request:
push:
jobs:
validation:
runs-on: ubuntu-20.04
outputs:
commitid: ${{steps.commitid.outputs.short}}
steps:
- name: Setup Dynamic Env
run: |
echo "MAKEFLAGS=-j$(nproc)" | tee $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to quay.io
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Figure Out Commit Short ID
id: commitid
run: |
echo ::set-output name=short::$(git rev-parse --short HEAD)
- name: Install nix
uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Fetch Nix Deps
run: nix-shell --command true
- name: Run formatters and linters
run: nix-shell --run .github/workflows/formatters-and-linters.sh
- name: Build Hook Tarballs
run: |
# fixes "write /run/user/1001/355792648: no space left on device" error
sudo mount -o remount,size=3G /run/user/1001 || true
nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} dist'
- name: Publish Hook
if: github.ref == 'refs/heads/main'
run: |
# Build and push the container images
nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} push'
nix-shell --run 'make TAG=latest push'
- uses: actions/upload-artifact@v3
with:
name: hook-${{steps.commitid.outputs.short}}
path: out/${{steps.commitid.outputs.short}}/rel/hook_*.tar.gz
publish-release-latest:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main'
needs: validation
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: hook-${{needs.validation.outputs.commitid}}
- name: Delete Tag
run: |
git tag -d latest || echo "no local tag to delete"
git push origin :latest -f || echo "no remote tag to delete"
- name: Generate Release Notes
run: |
generated_release_notes=$(gh api 'repos/{owner}/{repo}/releases/generate-notes' -F tag_name=latest --jq .body)
cat >>"$GITHUB_ENV" <<-EOF
RELEASE_NOTES<<RELEASE_NOTES_EOF
# :warning: :rotating_light: :boom: Note!!! :boom: :rotating_light: :warning:
The uploaded files will be updated on the next merge to main, as such download them before use to avoid surprises.
---
Commit: ${{needs.validation.outputs.commitid}}
---
$generated_release_notes
RELEASE_NOTES_EOF
EOF
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Update Tag
uses: rickstaa/action-create-tag@v1
with:
tag: latest
message: "Latest development build"
- name: Generate checksum
uses: jmgilman/actions-generate-checksum@v1
with:
method: sha512
patterns: hook_*.tar.gz
- name: Update latest release
uses: softprops/action-gh-release@v1
with:
name: Hook Latest Development Build
body: ${{env.RELEASE_NOTES}}
files: |
hook_*.tar.gz
checksum.txt
prerelease: true
tag_name: latest
publish-release-tag:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
needs: validation
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: hook-${{needs.validation.outputs.commitid}}
- name: Generate Release Notes
run: |
generated_release_notes=$(gh api 'repos/{owner}/{repo}/releases/generate-notes' -F tag_name=${{github.ref}} --jq .body)
cat >>"$GITHUB_ENV" <<-EOF
RELEASE_NOTES<<RELEASE_NOTES_EOF
$generated_release_notes
RELEASE_NOTES_EOF
EOF
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Generate checksum
uses: jmgilman/actions-generate-checksum@v1
with:
method: sha512
patterns: hook_*.tar.gz
- name: Update latest release
uses: softprops/action-gh-release@v1
with:
body: ${{env.RELEASE_NOTES}}
files: |
hook_*.tar.gz
checksum.txt