Build for linux and Mac now #45
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [darwin, linux] | |
arch: [arm64, amd64] | |
runs-on: ubuntu-latest | |
environment: production | |
env: | |
SELF_UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SELF_UPDATE_PRIVATE_KEY: ${{ secrets.SELF_UPDATE_PRIVATE_KEY }} | |
SELF_UPDATE_PUBLIC_KEY: ${{ secrets.SELF_UPDATE_PUBLIC_KEY }} | |
SELF_UPDATE_VERSION: ${{ github.ref_name }} | |
steps: | |
- name: Setup Go 1.21 | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.21 | |
- name: Setup Repo | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Run Unit Tests | |
run: go test -v ./... | |
- name: Build temporary cli | |
run: go build -o ./selfupdate ./cmd/selfupdate/main.go | |
- name: Create a Release | |
run: | | |
./selfupdate github release \ | |
--owner blockthrough \ | |
--repo selfupdate.go \ | |
--version ${{ env.SELF_UPDATE_VERSION }} \ | |
--title ${{ env.SELF_UPDATE_VERSION }} \ | |
--token ${{ env.SELF_UPDATE_GH_TOKEN }} | |
- name: Build and Sign | |
run: | | |
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} \ | |
go build \ | |
-ldflags "-X main.Version=${{ env.SELF_UPDATE_VERSION }} -X main.PublicKey=${{ env.SELF_UPDATE_PUBLIC_KEY }}" \ | |
-o ./selfupdate-${{ matrix.os }}-${{ matrix.arch }} \ | |
./cmd/selfupdate/main.go | |
- name: Upload New Release | |
run: | | |
./selfupdate github upload \ | |
--owner blockthrough \ | |
--repo selfupdate.go \ | |
--filename selfupdate-${{ matrix.os }}-${{ matrix.arch }}.sign \ | |
--version ${{ env.SELF_UPDATE_VERSION }} \ | |
--token ${{ env.SELF_UPDATE_GH_TOKEN }} \ | |
--key ${{ env.SELF_UPDATE_PRIVATE_KEY }} < ./selfupdate-${{ matrix.os }}-${{ matrix.arch }} | |
./selfupdate github upload \ | |
--owner blockthrough \ | |
--repo selfupdate.go \ | |
--filename selfupdate-${{ matrix.os }}-${{ matrix.arch }} \ | |
--version ${{ env.SELF_UPDATE_VERSION }} \ | |
--token ${{ env.SELF_UPDATE_GH_TOKEN }} < ./selfupdate-${{ matrix.os }}-${{ matrix.arch }} |