Skip to content

Merge pull request #208 from intelops/fix #31

Merge pull request #208 from intelops/fix

Merge pull request #208 from intelops/fix #31

Workflow file for this run

name: compage-release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
jobs:
push_to_registry:
name: Build and push Docker image github container registry.
runs-on: ubuntu-20.04
permissions:
packages: write
id-token: write
contents: read
actions: read
security-events: write
env:
REGISTRY: ghcr.io
GH_URL: https://github.com
steps:
- name: Set environment variable
run: |
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Test environment variable
run: echo ${{ env.RELEASE_VERSION }}
- name: Check out GitHub repo
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v5
with:
push: true
context: .
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }}
# - uses: goodwithtech/dockle-action@main
# with:
# image: ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }}
# format: 'list'
# exit-code: '1'
# exit-level: 'warn'
# ignore: 'CIS-DI-0001,DKL-DI-0006'
- name: Install cosign
uses: sigstore/cosign-installer@main
- name: Sign the images
run: |
cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }}
env:
COSIGN_EXPERIMENTAL: 1
- name: Verify the pushed tags
run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/release.yml@refs/tags/${{ env.RELEASE_VERSION }} --certificate-oidc-issuer https://token.actions.githubusercontent.com
env:
COSIGN_EXPERIMENTAL: 1
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
format: 'github'
output: 'dependency-results.sbom.json'
image-ref: '.'
github-pat: ${{ secrets.GH_TOKEN }}
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
token: ${{ secrets.GH_TOKEN }}
- run: git fetch --force --tags
- name: Initialize and update submodules
run: git submodule update --init --recursive
- name: List Nested Directories
run: |
# List all nested directories
find . -type f
- uses: actions/setup-go@v5
with:
go-version: 1.22
cache: true
- uses: sigstore/[email protected] # installs cosign
- uses: anchore/sbom-action/[email protected] # installs syft
- name: Install GoReleaser
run: go install github.com/goreleaser/goreleaser@latest
- name: Run GoReleaser
run: goreleaser release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: verify release
run: |
COMMIT=$(git rev-list --tags --max-count=1)
TAG=$(git describe --tags ${COMMIT})
wget https://github.com/intelops/compage/releases/download/${TAG}/checksums.txt
cosign verify-blob \
--certificate-identity "https://github.com/intelops/compage/.github/workflows/release.yml@refs/tags/${TAG}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
--cert "https://github.com/intelops/compage/releases/download/${TAG}/checksums.txt.pem" \
--signature "https://github.com/intelops/compage/releases/download/${TAG}/checksums.txt.sig" \
./checksums.txt