From 48c030dd1dabdf556bc695594e3bef632aa38387 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Mon, 11 Mar 2024 18:16:57 -0500 Subject: [PATCH] ci: Add build job --- .github/workflows/build.yaml | 88 ++++++++++++++++++++++++++++++++++++ .goreleaser.yaml | 42 +++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..0bd3c00 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..e606bab --- /dev/null +++ b/.goreleaser.yaml @@ -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