From e2df75f4c60953a220caec20a939bcb6b1fd4d3f Mon Sep 17 00:00:00 2001 From: LTLA Date: Sat, 2 Mar 2024 03:08:00 -0800 Subject: [PATCH] Added GitHub actions to test, build and publish. Also added some badges to link to the action outcomes. --- .github/workflows/build.yaml | 59 ++++++++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 36 +++++++++++++++++++++ README.md | 4 +++ 3 files changed, 99 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..a012b38 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,59 @@ +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.20' + cache-dependency-path: go.sum + + - name: Install dependencies + run: | + go get . + + - name: Run tests + run: 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: 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: gobbler-${{ matrix.os }}-${{ matrix.arch }} + overwrite: true + compress_assets: false diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..cffeb13 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -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: gobbler-${{ matrix.os }}-${{ matrix.arch }} + overwrite: true + compress_assets: false diff --git a/README.md b/README.md index bf34371..7ab82c9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Collecting random shit from a shared filesystem +[![Test and build](https://github.com/ArtifactDB/SewerRat/actions/workflows/build.yaml/badge.svg)](https://github.com/ArtifactDB/SewerRat/actions/workflows/build.yaml) +[![Publish version](https://github.com/ArtifactDB/SewerRat/actions/workflows/publish.yaml/badge.svg)](https://github.com/ArtifactDB/SewerRat/actions/workflows/publish.yaml) +[![Latest version](https://img.shields.io/github/v/tag/ArtifactDB/SewerRat?label=Version)](https://github.com/ArtifactDB/SewerRat/releases) + ## Introduction SewerRat retrieves user-supplied metadata from a shared filesystem and indexes them into a giant SQLite file.