-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (111 loc) · 3.73 KB
/
release.yml
File metadata and controls
126 lines (111 loc) · 3.73 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version (e.g., v1.2.3). Defaults to the ref name."
required: false
permissions:
contents: write
packages: write
jobs:
release:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Go installation
id: check-go
run: |
if command -v go &> /dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Go already installed: $(go version)"
GO_BIN_DIR=$(dirname $(command -v go))
echo "${GO_BIN_DIR}" >> $GITHUB_PATH
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Go not found"
fi
- name: Set up Go
if: steps.check-go.outputs.exists != 'true'
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Check Task installation
id: check-task
run: |
if command -v task &> /dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Task already installed: $(task --version)"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Task not found"
fi
- name: Set up Task
if: steps.check-task.outputs.exists != 'true'
uses: go-task/setup-task@v1
- name: Setup BuildKit cache
run: task setup:cache
- name: Check Docker Buildx
id: check-buildx
run: |
if command -v docker &> /dev/null && docker buildx version &> /dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Docker Buildx already available: $(docker buildx version)"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Docker Buildx not found"
fi
- name: Set up Docker Buildx
if: steps.check-buildx.outputs.exists != 'true'
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
use: true
name: spinbox-builder
driver-opts: |
image=moby/buildkit:latest
network=host
buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 4
[worker.containerd]
gc = true
gckeepstorage = 50000000000
[[worker.containerd.gcpolicy]]
keepBytes = 50000000000
keepDuration = 1209600
filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"]
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build release tarball
env:
VERSION: ${{ inputs.version || github.ref_name }}
run: task release
- name: Push sandbox image
env:
VERSION: ${{ inputs.version || github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: task release:image
- name: Upload release assets
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: _output/release/*.tar.gz
- name: Cleanup BuildKit cache
if: always()
run: |
find /var/lib/spinbox-buildkit-cache -type f -mtime +60 -delete || true
echo "BuildKit cache cleanup complete"