-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (119 loc) · 3.52 KB
/
Copy pathci.yml
File metadata and controls
143 lines (119 loc) · 3.52 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- name: Verify formatting
run: test -z "$(gofmt -l .)"
- name: Run static analysis
run: go vet ./...
- name: Run tests
run: go test -race -coverprofile=coverage.out ./...
- name: Build CLI
run: go build -trimpath -o bin/luago ./cmd/luago
- name: Smoke test CLI
shell: bash
run: |
actual="$(./bin/luago interpreter/testdata/arithmetic.lua)"
expected=$'12\n16'
test "$actual" = "$expected"
build:
name: Build Linux ${{ matrix.goarch }}
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goarch:
- amd64
- arm64
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- name: Build binary
env:
GOARCH: ${{ matrix.goarch }}
GOOS: linux
CGO_ENABLED: "0"
shell: bash
run: |
version="${GITHUB_SHA::12}"
package="luago-${GOOS}-${GOARCH}"
mkdir -p "dist/${package}"
go build \
-trimpath \
-ldflags="-s -w -X main.version=${version}" \
-o "dist/${package}/luago" \
./cmd/luago
cp README.md LICENSE.txt "dist/${package}/"
tar -C dist -czf "dist/${package}.tar.gz" "${package}"
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: luago-linux-${{ matrix.goarch }}
path: dist/luago-linux-${{ matrix.goarch }}.tar.gz
if-no-files-found: error
retention-days: 14
package-image:
name: Publish GHCR image
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository_owner }}/luago
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=short,prefix=sha-
- name: Build and optionally publish image
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.sha }}
provenance: false
sbom: false