Skip to content

Commit

Permalink
use go-release-action
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsNoahEvans committed Nov 6, 2023
1 parent d7e4945 commit 2b576ab
Showing 1 changed file with 25 additions and 97 deletions.
122 changes: 25 additions & 97 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,29 @@
name: Go Build & Release

on:
push:
branches:
- main

push:
branches:
- main

permissions:
contents: write
packages: write

jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21.3"

- name: Check out code
uses: actions/checkout@v2

- name: Get dependencies
run: go mod download

- name: Build Binary for Linux
run: GOOS=linux GOARCH=amd64 go build -o resizer-linux-amd64

- name: Build Binary for macOS
run: GOOS=darwin GOARCH=amd64 go build -o resizer-darwin-amd64

- name: Build Binary for macOS ARM
run: GOOS=darwin GOARCH=arm64 go build -o resizer-darwin-arm64

- name: Build Binary for Windows
run: GOOS=windows GOARCH=amd64 go build -o resizer-windows-amd64.exe

- name: Determine new tag
id: newtag
run: |
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
NEW_TAG="${TAG%.*}.$((${TAG##*.}+1))"
echo "Creating new tag $NEW_TAG"
echo "::set-output name=tag::$NEW_TAG"
shell: bash

- name: Push new tag
run: |
git config user.name github-actions
git config user.email [email protected]
git tag ${{ steps.newtag.outputs.tag }}
git push origin ${{ steps.newtag.outputs.tag }}
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.newtag.outputs.tag }}
release_name: Release ${{ steps.newtag.outputs.tag }}
draft: false
prerelease: false

- name: Upload Release Asset for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./resizer-linux-amd64
asset_name: resizer-linux-amd64
asset_content_type: application/octet-stream

- name: Upload Release Asset for macOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./resizer-darwin-amd64
asset_name: resizer-darwin-amd64
asset_content_type: application/octet-stream

- name: Upload Release Asset for macOS ARM
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./resizer-darwin-arm64
asset_name: resizer-darwin-arm64
asset_content_type: application/octet-stream

- name: Upload Release Asset for Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./resizer-windows-amd64.exe
asset_name: resizer-windows-amd64.exe
asset_content_type: application/octet-stream
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]

steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "1.21.3"
binary_name: "resizer"

0 comments on commit 2b576ab

Please sign in to comment.