Skip to content

minor updates

minor updates #9

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 and cache dependencies
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get the version
id: get_version
run: |
echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
if [ -z "$VERSION" ]; then
echo "VERSION is not set"
exit 1
fi
- 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: ${{ needs.build.outputs.VERSION }}
# - 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