Skip to content

Commit

Permalink
feat(ci): add release build and test stage for PRs (#79)
Browse files Browse the repository at this point in the history
* feat(ci): add go tests action

* feat(release): test release build on PR

* Update release.yml

Updated version to 1.21

* Update test.yml

Updated to version 1.21

---------

Co-authored-by: Brandon Tassone <btassone@users.noreply.github.com>
  • Loading branch information
FalcoSuessgott and btassone authored Feb 7, 2024
1 parent 39becb9 commit 252c245
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- '*'
pull_request:

permissions:
contents: write
Expand All @@ -23,12 +24,24 @@ jobs:
with:
go-version: "1.21"

-
# if tag release
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# if no tag test release build
-
name: Run GoReleaser skip publishing
uses: goreleaser/goreleaser-action@v5
if: "!startsWith(github.ref, 'refs/tags/v')"
with:
version: latest
args: release --skip=publish --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test and coverage

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false

- name: go get
run: go get ./...

- name: Run tests
run: go test -v ./...
12 changes: 7 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ builds:
-
id: plugin-check
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
# This will check plugin compatibility against latest version of Packer
post:
- go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
- bash -ec 'cd "{{ dir .Path}}" && packer-sdc plugin-check {{ .Name }}'
flags:
- -trimpath
ldflags:
Expand All @@ -39,6 +34,13 @@ builds:
- '386'
- arm
- arm64
ignore:
- goos: windows
goarch: arm64
- goos: darwin
goarch: '386'
- goos: linux
goarch: amd64
archives:
-
builds:
Expand Down

0 comments on commit 252c245

Please sign in to comment.