Skip to content

feat: adds image build, publish and sign #1

feat: adds image build, publish and sign

feat: adds image build, publish and sign #1

name: Build and Sign Image
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
image-build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
BASE_REPO: "ghcr.io/stacklok/vibetool"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: ko-build/setup-ko@d982fec422852203cfb2053a8ec6ad302280d04d # v0.8
with:
version: v0.16.0
- name: Compute version number
id: version-string
run: |
DATE="$(date +%Y%m%d)"
COMMIT="$(git rev-parse --short HEAD)"
echo "tag=0.$DATE.$GITHUB_RUN_NUMBER+ref.$COMMIT" >> "$GITHUB_OUTPUT"
- name: Login to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 #[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
- name: Setup KO
uses: ko-build/setup-ko@d982fec422852203cfb2053a8ec6ad302280d04d # v0.8
with:
version: v0.16.0
- name: Build and Push Image to GHCR
run: |
ko build --platform=linux/amd64,linux/arm64 --push=false ./cmd/vibetool \
--image-label=org.opencontainers.image.source=https://github.com/stacklok/vibetool,org.opencontainers.image.title="Vibetool",org.opencontainers.image.vendor=Stacklok
env:
KO_DOCKER_REPO: "$BASE_REPO"
- name: Sign Image with Cosign
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: |
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
# Sign the ko image
cosign sign --yes $BASE_REPO:$TAG