minor updates #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Release, and Publish | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
GO_VERSION: '1.22' | |
BINARY_NAME: 'ingest' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- os: darwin | |
arch: arm64 | |
- os: linux | |
arch: amd64 | |
- os: linux | |
arch: arm64 | |
outputs: | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Get the version | |
id: get_version | |
run: echo "VERSION=$(git describe --tags --always --abbrev=0)" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: go mod download | |
- name: Run tests | |
run: go test -v ./... | |
- name: Build | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
run: | | |
go build -v -ldflags "-X main.Version=$VERSION" -o build/${{ env.BINARY_NAME }}-${{ matrix.os }}-${{ matrix.arch }} . | |
ls -ltarh build/ | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
name: ${{ env.BINARY_NAME }}-${{ matrix.os }}-${{ matrix.arch }} | |
path: build/${{ env.BINARY_NAME }}-${{ matrix.os }}-${{ matrix.arch }} | |
retention-days: 90 | |
release: | |
name: Release | |
needs: build | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
path: build/ | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: build/ | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: | |
# - name: Update latest tag | |
# run: | | |
# git config user.name github-actions | |
# git config user.email [email protected] | |
# git tag -f latest | |
# git push origin latest --force |