| 1 |
# Copyright 2023 The Archivista Contributors |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
permissions: |
| 16 |
contents: read # This is required for actions/checkout |
| 17 |
name: pipeline |
| 18 |
on: |
| 19 |
push: |
| 20 |
tags: |
| 21 |
- v* |
| 22 |
branches: |
| 23 |
- main |
| 24 |
pull_request: |
| 25 |
jobs: |
| 26 |
fmt: |
| 27 |
uses: ./.github/workflows/witness.yml |
| 28 |
permissions: |
| 29 |
id-token: write # This is required for requesting the JWT |
| 30 |
contents: read # This is required for actions/checkout |
| 31 |
with: |
| 32 |
pull_request: ${{ github.event_name == 'pull_request' }} |
| 33 |
step: static-analysis |
| 34 |
attestations: "github" |
| 35 |
command: go fmt ./... |
| 36 |
|
| 37 |
static_analysis: |
| 38 |
uses: ./.github/workflows/witness.yml |
| 39 |
permissions: |
| 40 |
id-token: write # This is required for requesting the JWT |
| 41 |
contents: read # This is required for actions/checkout |
| 42 |
with: |
| 43 |
pull_request: ${{ github.event_name == 'pull_request' }} |
| 44 |
step: static-analysis |
| 45 |
attestations: "github" |
| 46 |
command: go vet ./... |
| 47 |
|
| 48 |
tests: |
| 49 |
needs: [fmt, static_analysis] |
| 50 |
uses: ./.github/workflows/witness.yml |
| 51 |
permissions: |
| 52 |
id-token: write # This is required for requesting the JWT |
| 53 |
contents: read # This is required for actions/checkout |
| 54 |
with: |
| 55 |
pull_request: ${{ github.event_name == 'pull_request' }} |
| 56 |
step: "tests" |
| 57 |
attestations: "github" |
| 58 |
command: | |
| 59 |
make clean |
| 60 |
make test |
| 61 |
|
| 62 |
release: |
| 63 |
needs: tests |
| 64 |
permissions: |
| 65 |
id-token: write |
| 66 |
contents: write |
| 67 |
packages: write |
| 68 |
runs-on: ubuntu-latest |
| 69 |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 70 |
|
| 71 |
steps: |
| 72 |
- name: Harden Runner |
| 73 |
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 |
| 74 |
with: |
| 75 |
egress-policy: audit |
| 76 |
|
| 77 |
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 78 |
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 |
| 79 |
with: |
| 80 |
go-version-file: "go.mod" |
| 81 |
|
| 82 |
- name: Login to GitHub Container Registry |
| 83 |
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 84 |
with: |
| 85 |
registry: ghcr.io |
| 86 |
username: ${{ github.actor }} |
| 87 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 88 |
|
| 89 |
- name: Set up QEMU |
| 90 |
uses: docker/setup-qemu-action@v3 |
| 91 |
|
| 92 |
- name: Set up Docker Buildx |
| 93 |
uses: docker/setup-buildx-action@v3 |
| 94 |
|
| 95 |
- name: Download GoReleaser |
| 96 |
run: go install github.com/goreleaser/[email protected] |
| 97 |
|
| 98 |
- name: Run GoReleaser |
| 99 |
uses: testifysec/witness-run-action@7aa15e327829f1f2a523365c564c948d5dde69dd |
| 100 |
env: |
| 101 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 |
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} |
| 103 |
with: |
| 104 |
witness-install-dir: /opt/witness |
| 105 |
version: 0.9.1 |
| 106 |
step: "build" |
| 107 |
attestations: "github" |
| 108 |
command: goreleaser release --clean |