Skip to content

Commit

Permalink
ci: add go workflow, update actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing authored Oct 26, 2024
1 parent 49e3687 commit c59fbc4
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 23 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to build and test.
name: "Go"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
GO_VERSION: "1.23.x"

jobs:
vulncheck:
name: "Vulnerability Check"
runs-on: "ubuntu-latest"
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true

- name: "Install govulncheck"
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: "Run govulncheck"
run: govulncheck ./...

build:
name: "Build (${{ matrix.os }})"
runs-on: "${{ matrix.os }}"
permissions:
contents: read
strategy:
matrix:
os: ["ubuntu-latest"]
steps:
- name: "Checkout repository"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true

- name: "Download dependencies"
run: go mod download

- name: "Verify dependencies"
run: go mod verify

- name: "Build"
run: go build ./...

- name: "Test"
run: go test ./...
30 changes: 7 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to create releases using GoReleaser.
name: "Release"
Expand All @@ -42,28 +26,28 @@ jobs:
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0

- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true

- name: "Install cosign"
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
uses: sigstore/cosign-installer@1aa8e0f2454b781fbf0fbf306a4c9533a0c57409 # v3.7.0

- name: "Install Syft"
uses: anchore/sbom-action/download-syft@d94f46e13c6c62f59525ac9a1e147a99dc0b9bf5 # v0.17.0
uses: anchore/sbom-action/download-syft@1ca97d9028b51809cf6d3c934c3e160716e1b605 # v0.17.5

- name: "Setup QEMU"
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0

- name: "Setup Docker Buildx"
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1

- name: "Login to DockerHub"
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand Down

0 comments on commit c59fbc4

Please sign in to comment.