Skip to content

fix: add --always to git describe in ci #30

fix: add --always to git describe in ci

fix: add --always to git describe in ci #30

name: Build and Test
on:
release:
types: [ "published" ]
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
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}
- {GOOS: freebsd, GOARCH: amd64}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build
run: |
DIR="$(mktemp -d)"
mkdir "$DIR/age-plugin-sss"
cp LICENSE $DIR/age-plugin-sss
VERSION="$(git describe --tags --always)"
go build -o "$DIR/age-plugin-sss" -ldflags "-X main.Version=$VERSION" -v ./cmd/...
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: 0
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: ${{ matrix.GOARM }}
- name: Upload workflow artifacts
uses: actions/upload-artifact@v2
with:
name: plugin-binaries
path: age-plugin-sss*
- name: Test
run: go test -v ./...
- name: Test E2E
run: |
export GOBIN="$HOME/.local/bin/"
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
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 }}