Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from aquaproj/chore/cosign
Browse files Browse the repository at this point in the history
chore: sign checksusm file by Cosign
  • Loading branch information
suzuki-shunsuke authored Jan 6, 2023
2 parents eea9b29 + 00d3fb7 commit becf631
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 44 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export AQUA_POLICY_CONFIG=$PWD/aqua-policy.yaml:$AQUA_POLICY_CONFIG
63 changes: 20 additions & 43 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ on:
push:
tags:
- "v*"
permissions:
contents: write # required to create a release
id-token: write # required for cosign
env:
AQUA_POLICY_CONFIG: ${{ github.workspace }}/aqua-policy.yaml
jobs:
build:
runs-on: ubuntu-latest
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
permissions:
contents: write # required to create a release
id-token: write # required for cosign
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version: "1.19.3"
go-version: "1.19.4"
- uses: aquaproj/aqua-installer@61e2563dfe7674cbf74fe6ec212e444198a3bb00 # v2.0.2
with:
aqua_version: v1.30.1
- run: cosign version
- name: Run GoReleaser
id: run-goreleaser
uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 # v4.1.0
with:
version: latest
args: release --rm-dist --skip-publish
version: v1.14.1 # renovate: depName=goreleaser/goreleaser
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3
with:
name: artifacts
path: |
dist/*.tar.gz
dist/*.sig
dist/*.pem
dist/*_checksums.txt
- name: Generate hashes
- name: Generate subject
id: hash
env:
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
run: |
# sha256sum generates sha256 hash for all artifacts.
# base64 -w0 encodes to base64 and outputs on a single line.
# sha256sum artifact1 artifact2 ... | base64 -w0
echo "hashes=$(find dist -name "*.tar.gz" -print0 | xargs -0 sha256sum | base64 -w0)" >> "$GITHUB_OUTPUT"
set -euo pipefail
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
echo "hashes=$(cat $checksum_file | base64 -w0)" >> "$GITHUB_OUTPUT"
provenance:
needs: [build]
Expand All @@ -54,27 +54,4 @@ jobs:
with:
base64-subjects: "${{ needs.build.outputs.hashes }}"
# Upload provenance to a new release
upload-assets: false

release:
needs: [provenance]
runs-on: ubuntu-latest
steps:
- run: mkdir -p dist/artifacts dist/provenance
- name: Download the provenance
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
with:
name: ${{ needs.provenance.outputs.provenance-name }}
path: dist/provenance/${{ needs.provenance.outputs.provenance-name }}
- name: Download artifacts
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
with:
name: artifacts
path: dist/artifacts

- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
prerelease: true
files: |
dist/**/*
upload-assets: true
19 changes: 18 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@ builds:
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
release:
draft: true # we update release note manually before releasing
prerelease: true # we update release note manually before releasing
signs:
- cmd: cosign
artifacts: checksum
signature: ${artifact}.sig
certificate: ${artifact}.pem
output: true
env:
- COSIGN_EXPERIMENTAL=1
args:
- sign-blob
- --output-signature
- ${signature}
- --output-certificate
- ${certificate}
- --oidc-provider
- github
- ${artifact}
8 changes: 8 additions & 0 deletions aqua-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# aqua Policy
# https://aquaproj.github.io/docs/tutorial-extras/policy-as-code
registries:
- type: standard
ref: semver(">= 3.0.0")
packages:
- registry: standard
14 changes: 14 additions & 0 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# # https://aquaproj.github.io/docs/reference/checksum/
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v3.116.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: sigstore/[email protected]
1 change: 1 addition & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": [
"config:base",
"helpers:pinGitHubActionDigests",
"github>aquaproj/aqua-renovate-config#1.5.0",
"github>suzuki-shunsuke/renovate-config"
],
"packageRules": [
Expand Down

0 comments on commit becf631

Please sign in to comment.