Skip to content

Commit

Permalink
Merge pull request #5 from rayspock/feat/add-workflow
Browse files Browse the repository at this point in the history
Create workflows
  • Loading branch information
rayspock committed Apr 24, 2023
2 parents 849338c + 43cc95f commit 2ca92d9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
name: Run tests
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version-file: "go.mod"
cache: true
- run: make test

build:
name: Build binary
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
goarch: [amd64, arm64]
exclude:
- os: windows-latest
goarch: arm64
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Build
run: env GOARCH=${{ matrix.goarch }} make

36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
release:
types: [created]

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
exclude:
- goarch: arm64
goos: windows
steps:
- name: Get Release Info
run: |
{
echo "RELEASE_TAG=${GITHUB_REF/refs\/tags\//}"
echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}"
echo "OS_NAME=${{ matrix.goos }}"
} >> "$GITHUB_ENV"
- name: OS darwin
if: matrix.goos == 'darwin'
run: echo "OS_NAME=macOS" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://dl.google.com/go/go1.20.3.linux-amd64.tar.gz"
extra_files: LICENSE.txt README.md .env.example
md5sum: false
build_command: make

0 comments on commit 2ca92d9

Please sign in to comment.