Skip to content

chore: add makefile and pass version as build arg #76

chore: add makefile and pass version as build arg

chore: add makefile and pass version as build arg #76

name: Build and Test
on:
release:
types: [ "published" ]
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
GO_VERSION: '>=1.21'
CGO_ENABLED: 0
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {GOOS: linux, GOARCH: amd64}
- {GOOS: linux, GOARCH: arm, GOARM: 6}
- {GOOS: linux, GOARCH: arm64}
- {GOOS: darwin, GOARCH: amd64}
- {GOOS: darwin, GOARCH: arm64}
# - {GOOS: windows, GOARCH: amd64} TODO: figure out how to fix build
- {GOOS: freebsd, GOARCH: amd64}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Test
run: go test -v ./...
- name: Package
run: |
VERSION="$(git describe --tags --always)"
go build -ldflags "-X main.Version=$VERSION" -v ./cmd/...
DIR="$(mktemp -d)"
mkdir "$DIR/age-plugin-sss"
cp LICENSE "$DIR/age-plugin-sss"
mv age-plugin-sss "$DIR/age-plugin-sss"
if [ "$GOOS" == "windows" ]; then
( cd "$DIR"; zip age-plugin-sss.zip -r age-plugin-sss )
mv "$DIR/age-plugin-sss.zip" "age-plugin-sss-$VERSION-$GOOS-$GOARCH.zip"
else
tar -cvzf "age-plugin-sss-$VERSION-$GOOS-$GOARCH.tar.gz" -C "$DIR" age-plugin-sss
fi
env:
CGO_ENABLED: ${{ env.CGO_ENABLED }}
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: ${{ matrix.GOARM }}
- name: Test E2E
if: matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64'
run: |
export GOBIN="$HOME/.local/bin/"
go build -v ./cmd/...
go install github.com/rogpeppe/go-internal/cmd/testscript@v1.12.0
go install filippo.io/age/cmd/...@latest
cp age-plugin-sss "$HOME/.local/bin/age-plugin-sss"
testscript ./testdata/*.txt
rm age-plugin-sss
- name: Upload workflow artifacts
uses: actions/upload-artifact@v2
with:
name: plugin-binaries
path: age-plugin-sss*
release:
name: Upload release binaries
if: github.event_name == 'release'
needs: build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download workflow artifacts
uses: actions/download-artifact@v2
with:
name: plugin-binaries
- name: Upload release artifacts
run: gh release upload "$GITHUB_REF_NAME" age-plugin-sss*
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}