Skip to content

chore(deps): pin dependencies [skip-ci] #49

chore(deps): pin dependencies [skip-ci]

chore(deps): pin dependencies [skip-ci] #49

name: Build, Release, and Publish
on:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
pull_request:
branches: [ main ]
paths-ignore:
- 'README.md'
env:
GO_VERSION: '1.22'
BINARY_NAME: 'ingest'
permissions:
contents: write
packages: write
jobs:
build:
if: ${{ ! contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.pull_request.title, '[skip ci]')}}
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: darwin
arch: arm64
- os: linux
arch: amd64
- os: linux
arch: arm64
outputs:
version: ${{ steps.set_version.outputs.new_tag }}
changelog: ${{ steps.set_version.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Set up Go and cache dependencies
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get version
id: set_version
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
- 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.set_version.outputs.new_tag }}
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@834a144ee995460fba8ed112a2fc961b36a5ec5a # 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' && !contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.pull_request.title, '[skip ci]')}}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
path: build/
- name: Create a GitHub release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1
if: ${{ startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.pull_request.title, '[skip ci]') }}
with:
tag: ${{ needs.build.outputs.version }}
name: ${{ needs.build.outputs.version }}
body: ${{ needs.build.outputs.changelog }}
skipIfReleaseExists: true
generateReleaseNotes: true
allowUpdates: true
makeLatest: ${{ startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.pull_request.title, '[skip ci]') }}
prerelease: ${{ !startsWith(github.ref, 'refs/heads/main') }}
artifactErrorsFailBuild: true
artifacts: |
build/${{ env.BINARY_NAME }}*/${{ env.BINARY_NAME }}*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}