Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Dec 16, 2023
1 parent 671fa7b commit d9f88a9
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build
on:
release:
types: [published]
push:
pull_request:
permissions:
contents: read
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
environment: "Build, release binaries"
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: freebsd, GOARCH: amd64}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.x
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build binary
run: |
VERSION="$(git describe --tags)"
DIR="$(mktemp -d)"
mkdir "$DIR/ical-git"
go build -o "$DIR/ical-git" -ldflags "-X main.Version=$VERSION" -trimpath ./cmd/...
tar -cvzf "ical-git-$VERSION-$GOOS-$GOARCH.tar.gz" -C "$DIR" ical-git
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: ${{ matrix.GOARM }}
- name: Upload workflow artifacts
uses: actions/upload-artifact@v3
with:
name: ical-git-binaries
path: ical-git-*
upload:
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@v3
with:
name: ical-git-binaries
- name: Upload release artifacts
run: gh release upload "$GITHUB_REF_NAME" ical-git-*
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

0 comments on commit d9f88a9

Please sign in to comment.