Skip to content

Commit

Permalink
feat: add release ci
Browse files Browse the repository at this point in the history
  • Loading branch information
olastor committed Jan 7, 2024
1 parent 7082dda commit 55266f7
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build and Test

on:
release:
types: [ "published" ]
push:
branches: [ "main" ]
pull_request:
Expand Down Expand Up @@ -28,7 +30,29 @@ jobs:
go-version: '1.21'

- name: Build
run: go build -v ./cmd/...
run: |
DIR="$(mktemp -d)"
mkdir "$DIR/age-plugin-sss"
cp LICENSE $DIR/age-plugin-sss
VERSION="$(git describe --tags)"
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 ./...
Expand All @@ -40,3 +64,21 @@ jobs:
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 }}

0 comments on commit 55266f7

Please sign in to comment.