Skip to content

Commit

Permalink
just use a makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Oct 16, 2024
1 parent 51cc4c9 commit 7fd4baf
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 42 deletions.
81 changes: 66 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
name: release
name: build

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- "v*"
permissions:
contents: write
- 'v*'
pull_request:

env:
DESTDIR: ./bin
GO_VERSION: 1.23.1

jobs:
release-tag:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: |
make build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: credential
path: credential-*
if-no-files-found: error

windows_build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -16,14 +45,36 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
cache: false
go-version: "1.23"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
go-version: ${{ env.GO_VERSION }}
- name: Build
run: |
make build-windows
- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: credential-windows
path: credential-*.exe
if-no-files-found: error

create_release:
runs-on: ubuntu-latest
needs: [ build, windows_build ]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- run: sleep 10
- name: Download all artifacts
uses: actions/download-artifact@v4
- run: ls -lR
- run: |
make checksums
- name: Create Release
uses: ncipollo/release-action@v1
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "./credential-*,./checksums.txt"
makeLatest: ${{ !contains(github.ref_name, '-rc') }}
generateReleaseNotes: true
prerelease: ${{ contains(github.ref_name, '-rc') }}
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .goreleaser.yml

This file was deleted.

32 changes: 31 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
VERSION=$(shell git describe --tags --always --dirty)

# Build target for darwin and linux for both amd64 and arm64
build:
CGO_ENABLED=0 go build -o bin/gptscript-go-tool -ldflags "-s -w"
@echo "Building for darwin and linux..."
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o credential-darwin-amd64 ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o credential-darwin-arm64 ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o credential-linux-amd64 ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o credential-linux-arm64 ./...

# Build target for windows for both amd64 and arm64
build-windows:
@echo "Building for windows..."
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o credential-windows-amd64.exe ./...
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "-s -w" -o credential-windows-arm64.exe ./...

checksums:
@echo "Creating checksums..."
sha256sum -b credential-* > checksums.txt
sha256sum -c --strict checksums.txt

# Clean up binaries
clean:
@echo "Cleaning up..."
rm -f credential-darwin-amd64
rm -f credential-darwin-arm64
rm -f credential-linux-amd64
rm -f credential-linux-arm64
rm -f credential-windows-amd64.exe
rm -f credential-windows-arm64.exe

.PHONY: build build-windows clean

0 comments on commit 7fd4baf

Please sign in to comment.