-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Release workflow with goreleaser (#202)
* Fix Signed-off-by: Ondrej Fabry <[email protected]> * Add blank lines to workflows for readability Signed-off-by: Ondrej Fabry <[email protected]> * Upload artifacts in release workflow Signed-off-by: Ondrej Fabry <[email protected]> * Update step in release workflow Signed-off-by: Ondrej Fabry <[email protected]> * Add newline at the end of file Signed-off-by: Ondrej Fabry <[email protected]> --------- Signed-off-by: Ondrej Fabry <[email protected]>
- Loading branch information
1 parent
c703bfe
commit 97d8772
Showing
6 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Run YAML linter" | ||
uses: ibiqlik/action-yamllint@v3 | ||
with: | ||
|
@@ -35,15 +36,19 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: "Run go mod tidy" | ||
run: go mod tidy -v | ||
|
||
- name: "Check go.mod" | ||
run: | | ||
git diff --exit-code go.mod | ||
- name: "Check go.sum" | ||
run: | | ||
git diff --exit-code go.sum | ||
|
@@ -59,12 +64,15 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: "Generate binapi" | ||
run: make gen-binapi-docker | ||
|
||
- name: "Check binapi" | ||
run: | | ||
git diff --exit-code binapi | ||
|
@@ -79,18 +87,23 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: "Setup gotestsum" | ||
uses: autero1/[email protected] | ||
with: | ||
gotestsum_version: 1.11.0 | ||
|
||
- name: "Go Build" | ||
run: go build -v ./... | ||
|
||
- name: "Go Test" | ||
run: gotestsum --format testname --jsonfile test.json -- -race ./... | ||
|
||
- name: "Test results" | ||
if: always() | ||
uses: guyarb/[email protected] | ||
|
@@ -109,10 +122,12 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: "Run golangci" | ||
uses: golangci/golangci-lint-action@v4 # docs: https://github.com/golangci/golangci-lint-action | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
issues: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@v5 | ||
|
||
- name: "Download Syft" | ||
uses: anchore/sbom-action/download-syft@v0 #v0.15.10 | ||
|
||
- name: "Release Version" | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
HOSTNAME: github | ||
|
||
- name: "Release Snapshot" | ||
if: success() && !startsWith(github.ref, 'refs/tags/v') | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: release --clean --snapshot | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
HOSTNAME: github | ||
|
||
- name: "Upload Artifacts" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: govpp-artifacts | ||
path: | | ||
dist/* | ||
!dist/govpp-build* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
.cache/ | ||
|
||
/bin/ | ||
/dist/ | ||
/govpp | ||
|
||
# cmd | ||
cmd/binapi-generator/binapi-generator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# GoReleser config | ||
# | ||
# documentation at http://goreleaser.com | ||
--- | ||
project_name: govpp | ||
|
||
builds: | ||
- id: govpp-build | ||
main: ./cmd/govpp | ||
binary: govpp | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
ignore: | ||
- goos: darwin | ||
goarch: "386" | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
- -X go.fd.io/govpp/version.version=v{{.Version}} | ||
- -X go.fd.io/govpp/version.commit={{.FullCommit}} | ||
- -X go.fd.io/govpp/version.branch={{.Branch}} | ||
- -X go.fd.io/govpp/version.buildStamp={{.Timestamp}} | ||
|
||
archives: | ||
- id: govpp-archive | ||
builds: | ||
- govpp-build | ||
format: tar.gz | ||
wrap_in_directory: true | ||
files: | ||
- README.md | ||
- docs/* | ||
allow_different_binary_count: true | ||
name_template: "govpp_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
changelog: | ||
skip: false | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '!^docs:' | ||
- typo | ||
|
||
dockers: | ||
- dockerfile: Dockerfile.govpp | ||
image_templates: | ||
- "ghcr.io/fdio/govpp:{{ .Tag }}" | ||
- "ghcr.io/fdio/govpp:v{{ .Major }}.{{ .Minor }}" | ||
- "ghcr.io/fdio/govpp:latest" | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
ids: | ||
- govpp-build | ||
|
||
sboms: | ||
- artifacts: archive | ||
|
||
release: | ||
github: | ||
owner: FDio | ||
name: govpp | ||
ids: | ||
- govpp-archive | ||
draft: true | ||
prerelease: auto | ||
name_template: "{{.Tag}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM scratch | ||
COPY govpp / | ||
ENTRYPOINT ["/govpp"] |