Skip to content

Commit

Permalink
ci: Add build job
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Mar 11, 2024
1 parent fbe2790 commit 48c030d
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build

on: push

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v4
with:
args: --timeout=5m

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
run: go test ./...

build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set build variables
id: vars
run: |
args='release --clean'
if [[ "$GITHUB_REF" != refs/tags/* ]]; then
args+=' --snapshot'
fi
echo "args=$args" >> $GITHUB_OUTPUT
- name: Generate Token
id: app-token
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
repositories: changelog-generator,homebrew-tap
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: ${{ steps.vars.outputs.args }}
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
42 changes: 42 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
project_name: changelog-generator
builds:
- env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s
- -w
- -X main.version=v{{.Version}}
- -X main.commit={{.ShortCommit}}
- -X main.date={{.CommitDate}}
- -X main.builtBy=goreleaser
goarch:
- amd64
- arm64
mod_timestamp: "{{.CommitTimestamp}}"
archives:
- format: tar.gz
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-beta"
changelog:
sort: asc
filters:
exclude:
- '^docs'
- '^test'
groups:
- title: Features
order: 0
regexp: "(feat)"
- title: Fixes
order: 1
regexp: "(fix|perf)"
- title: Others
order: 999

0 comments on commit 48c030d

Please sign in to comment.