diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 946c644..e73aedf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 @@ -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 }} diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 30e04e8..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: 2 -dist: releases -builds: - - id: credential - binary: "credential" - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - flags: - - "-trimpath" - ldflags: - - "-s -w" - env: - - CGO_ENABLED=0 - mod_timestamp: "{{ .CommitTimestamp }}" -checksum: - name_template: "checksums.txt" - algorithm: sha256 -release: - github: - owner: "g-linville" - name: "credential" diff --git a/Makefile b/Makefile index a684a53..31811d2 100644 --- a/Makefile +++ b/Makefile @@ -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" \ No newline at end of file + @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