Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Release workflow with goreleaser #202

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Run YAML linter"
uses: ibiqlik/action-yamllint@v3
with:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/release.yaml
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*
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Setup Go"
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: "Run Tests"
run: |
make test-integration
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
.cache/

/bin/
/dist/
/govpp

# cmd
cmd/binapi-generator/binapi-generator
Expand Down
81 changes: 81 additions & 0 deletions .goreleaser.yml
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}}"
3 changes: 3 additions & 0 deletions Dockerfile.govpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY govpp /
ENTRYPOINT ["/govpp"]
Loading