diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a510fa83..21cb8513 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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/action-gotestsum@v2.0.0 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/golang-test-annotations@v0.8.0 @@ -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: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..b861b76d --- /dev/null +++ b/.github/workflows/release.yaml @@ -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* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1de0a3ec..77ff23df 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/.gitignore b/.gitignore index a441bccb..04e752e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ .cache/ /bin/ +/dist/ +/govpp # cmd cmd/binapi-generator/binapi-generator diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..3221f787 --- /dev/null +++ b/.goreleaser.yml @@ -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}}" diff --git a/Dockerfile.govpp b/Dockerfile.govpp new file mode 100644 index 00000000..b7e3bd84 --- /dev/null +++ b/Dockerfile.govpp @@ -0,0 +1,3 @@ +FROM scratch +COPY govpp / +ENTRYPOINT ["/govpp"]