-
Notifications
You must be signed in to change notification settings - Fork 22
149 lines (137 loc) · 4.35 KB
/
release.yaml
File metadata and controls
149 lines (137 loc) · 4.35 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
# Reference from:
# https://goreleaser.com/ci/actions/
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
image:
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
image_url: ${{ steps.hash.outputs.image_url }}
image_digest: ${{ steps.hash.outputs.image_digest }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Setup QEMU
uses: docker/setup-qemu-action@v4
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4
- name: Docker login ghcr.io
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: kclbot
password: ${{ secrets.DEPLOY_ACCESS_TOKEN }}
- name: Docker login docker.io
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: |
kcllang/kcl
ghcr.io/kcl-lang/kcl
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
sbom: true
provenance: true
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
binary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_ACCESS_TOKEN }}
musl-binary:
needs: binary
runs-on: ubuntu-latest
container: golang:1.25-alpine
steps:
- name: Git checkout
uses: actions/checkout@v6
- name: Install musl dependencies (Alpine container)
run: |
apk add --no-cache \
musl-dev \
gcc \
git \
make \
linux-headers \
tar
- name: Compile KCL (musl static build)
run: |
CGO_ENABLED=1 go build -tags="musl netgo static osusergo" -ldflags="-linkmode external -extldflags '-static'" ./cmd/kcl
env:
CGO_LDFLAGS: '-static'
- name: Package musl binary with docs
run: |
TAG_NAME=${{ github.ref_name }}
mkdir -p kcl-musl-package
cp -f ./kcl ./kcl-musl-package/
cp -f ./README.md ./kcl-musl-package/
cp -f ./LICENSE ./kcl-musl-package/
tar -czf kcl-${TAG_NAME}-linux-musl-amd64.tar.gz -C kcl-musl-package .
ls -lh kcl-${TAG_NAME}-linux-musl-amd64.tar.gz
echo "PACKAGE_NAME=kcl-${TAG_NAME}-linux-musl-amd64.tar.gz" >> $GITHUB_ENV
- name: Upload musl package to Artifact
uses: actions/upload-artifact@v6
with:
name: kcl-musl-package
path: ./${{ env.PACKAGE_NAME }}
retention-days: 7
upload-musl-to-release:
needs: [binary, musl-binary]
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v6
- name: Download musl package from Artifact
uses: actions/download-artifact@v8
with:
name: kcl-musl-package
path: ./
- name: Install GitHub CLI
run: |
sudo apt update && sudo apt install -y gh
- name: Upload to GitHub Release
run: |
echo "${{ secrets.DEPLOY_ACCESS_TOKEN }}" | gh auth login --with-token
PACKAGE_NAME=$(ls ./kcl-*.tar.gz)
gh release upload "${{ github.ref_name }}" "${PACKAGE_NAME}" --clobber
env:
GITHUB_API_URL: https://api.github.com