Skip to content

test: make root tests easier to run #1361

test: make root tests easier to run

test: make root tests easier to run #1361

Workflow file for this run

name: Binaries
on:
push:
tags: [v*]
branches: [master]
pull_request:
branches: [master]
release:
types: [published]
jobs:
create-binaries:
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64, ppc64le, riscv64, s390x]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Build binary and create archive
id: build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
echo Generating version file
go generate ./cmd
echo Building for $GOOS $GOARCH
go build -trimpath -ldflags='-s -w' -o dist/build/pebble ./cmd/pebble
# Get version via "pebble version" to ensure it matches that exactly
PEBBLE_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/pebble version --client)
ARCHIVE_FILE=pebble_${PEBBLE_VERSION}_${GOOS}_${GOARCH}.tar.gz
echo Creating archive $ARCHIVE_FILE
cp COPYING dist/build
cp README.md dist/build
tar -czf dist/$ARCHIVE_FILE -C dist/build $(ls -A dist/build)
# Share variables with subsequent steps
echo "ARCHIVE_FILE=${ARCHIVE_FILE}" >>$GITHUB_OUTPUT
echo "PEBBLE_VERSION=${PEBBLE_VERSION}" >>$GITHUB_OUTPUT
- name: Upload archive as Actions artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.ARCHIVE_FILE }}
path: dist/${{ steps.build.outputs.ARCHIVE_FILE }}
- name: Upload archive to release
env:
ARCHIVE_FILE: ${{ steps.build.outputs.ARCHIVE_FILE }}
PEBBLE_VERSION: ${{ steps.build.outputs.PEBBLE_VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'release' }}
run: |
echo Uploading $ARCHIVE_FILE to release $PEBBLE_VERSION
gh release upload $PEBBLE_VERSION dist/$ARCHIVE_FILE