Skip to content

Commit

Permalink
Added some actions for testing and publishing binaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Oct 21, 2024
1 parent 69e7bc9 commit 18b8dda
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Unit tests

on:
push:
branches:
- master
paths:
- '**.go'
- 'go.**'
- .github/workflows/build.yaml
pull_request:
paths:
- '**.go'
- 'go.**'
- .github/workflows/build.yaml

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
cache-dependency-path: go.sum

- name: Install dependencies
run: |
go get .
- name: Download SewerRat
uses: wei/wget@v1
with:
args: -O SewerRat https://github.com/ArtifactDB/SewerRat/releases/download/latest/SewerRat-linux-amd64

- name: Run tests
run: |
chmod 755 SewerRat
./SewerRat &
go test -v
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
strategy:
matrix:
os: [ linux, darwin ]
arch: [ amd64, arm64 ]

steps:
- name: Check out
uses: actions/checkout@v4

- name: Shift tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/latest',
sha: context.sha
});
- name: Build latest
uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.os }}
goarch: ${{ matrix.arch }}
release_tag: latest
asset_name: SewerRat-${{ matrix.os }}-${{ matrix.arch }}
overwrite: true
compress_assets: false
36 changes: 36 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish version

on:
push:
tags:
- "*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Create release
uses: softprops/action-gh-release@v1

publish:
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
os: [ linux, darwin ]
arch: [ amd64, arm64 ]

steps:
- name: Check out
uses: actions/checkout@v4

- name: Publish binaries
uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.os }}
goarch: ${{ matrix.arch }}
release_tag: ${{ github.ref_name }}
asset_name: SewerRat-${{ matrix.os }}-${{ matrix.arch }}
overwrite: true
compress_assets: false

0 comments on commit 18b8dda

Please sign in to comment.