Skip to content

Commit f835696

Browse files
committed
ci: add build, lint and release workflows
1 parent ebd92c0 commit f835696

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

.github/workflows/build-release.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
tags:
7+
- v*
8+
9+
# Needed to create releases.
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
prepare-release:
15+
name: Conditionally prepare release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- if: github.event_name == 'push'
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
run: |-
23+
gh release create "${{ github.ref_name }}"
24+
25+
build:
26+
name: Build
27+
runs-on: ubuntu-latest
28+
needs: [ prepare-release ]
29+
permissions:
30+
contents: write
31+
strategy:
32+
matrix:
33+
goos: [ linux ]
34+
goarch: [ amd64, arm64 ]
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Extract k6 version from go.mod
38+
id: version
39+
run: |-
40+
k6version=$(grep -e go.k6.io go.mod | cut -d' ' -f 2)
41+
echo "Detected k6 version: ${k6version}"
42+
echo "k6=${k6version}" >> $GITHUB_OUTPUT
43+
- name: Build with xk6
44+
run: |-
45+
docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
46+
-e "GOOS=${{ matrix.goos }}" -e "GOARCH=${{ matrix.goarch }}" \
47+
grafana/xk6 build ${{ steps.version.outputs.k6 }} \
48+
--output "dist/sm-k6-${{ matrix.goos }}-${{ matrix.goarch }}" \
49+
--with sm=.
50+
- name: Upload artifact to release
51+
if: github.event_name == 'push'
52+
env:
53+
GH_TOKEN: ${{ github.token }}
54+
run: |-
55+
gh release upload "${{ github.ref_name }}" dist/*

.github/workflows/lint.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Lint
2+
3+
on:
4+
pull_request: {}
5+
6+
jobs:
7+
golangci:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: golangci-lint
13+
uses: golangci/golangci-lint-action@v6
14+
with:
15+
only-new-issues: true
16+
args: --timeout=5m # 1m is not enough, experimentally.

0 commit comments

Comments
 (0)