v0.4.0 #293
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
pull_request: {} | |
release: | |
types: [published] | |
# Needed to upload assets to releases. | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, darwin] | |
goarch: [amd64, arm64] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5 | |
- name: Extract k6 version from go.mod | |
id: version | |
run: |- | |
k6version=$(grep -e go.k6.io go.mod | cut -d' ' -f 2) | |
echo "Detected k6 version: ${k6version}" | |
echo "k6=${k6version}" >> $GITHUB_OUTPUT | |
- name: Build with xk6 | |
run: |- | |
mkdir -p dist | |
docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \ | |
-e "GOOS=${{ matrix.goos }}" -e "GOARCH=${{ matrix.goarch }}" \ | |
grafana/xk6 build ${{ steps.version.outputs.k6 }} \ | |
--output "dist/sm-k6-${{ matrix.goos }}-${{ matrix.goarch }}" \ | |
--with github.com/grafana/xk6-sm=. | |
# TODO(d0ugal): Remove this once the above build catches up and downstream consumers are updated. | |
- name: Build with xk6 and gsm | |
run: |- | |
mkdir -p dist | |
docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \ | |
-e "GOOS=${{ matrix.goos }}" -e "GOARCH=${{ matrix.goarch }}" \ | |
grafana/xk6 build ${{ steps.version.outputs.k6 }} \ | |
--output "dist/sm-k6-${{ matrix.goos }}-${{ matrix.goarch }}-gsm" \ | |
--with github.com/grafana/xk6-sm=. \ | |
--with github.com/grafana/gsm-api-go-client@64c2eb5 | |
- name: Check runner architecture | |
id: runner-info | |
run: |- | |
native="false" runner_arch="${{runner.arch}}" runner_os="${{runner.os}}" goos="${{matrix.goos}}" goarch="${{matrix.goarch}}" | |
if [[ "${runner_arch/X/amd}" = "$goarch" ]] && [[ "${runner_os,,}" = "$goos" ]]; then | |
native="true" | |
fi | |
echo "native=$native" >> $GITHUB_OUTPUT | |
- name: Test | |
# No point in running tests for foreign architectures we cannot run. | |
if: steps.runner-info.outputs.native == 'true' | |
run: |- | |
go test ./... | |
- name: Upload artifact to release | |
if: github.event_name == 'release' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: |- | |
gh release upload "${{ github.ref_name }}" dist/* --clobber |