|
| 1 | +# SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
| 11 | +permissions: {} |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + name: Release Container |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | + id-token: write |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Checkout propolis (sibling dependency) |
| 28 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
| 29 | + with: |
| 30 | + repository: stacklok/propolis |
| 31 | + ref: 6a81046b0472c54c877b965c34c97c094f373d74 # v0.1.0 |
| 32 | + path: ../propolis |
| 33 | + |
| 34 | + - name: Set up Go |
| 35 | + uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6 |
| 36 | + with: |
| 37 | + go-version-file: 'go.mod' |
| 38 | + cache: true |
| 39 | + |
| 40 | + - name: Install Task |
| 41 | + uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2 |
| 42 | + with: |
| 43 | + version: '3.x' |
| 44 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Test |
| 47 | + run: task test |
| 48 | + |
| 49 | + - name: Setup Ko |
| 50 | + uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9 |
| 51 | + |
| 52 | + - name: Log in to GitHub Container Registry |
| 53 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 |
| 54 | + with: |
| 55 | + registry: ghcr.io |
| 56 | + username: ${{ github.actor }} |
| 57 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + - name: Extract tag version |
| 60 | + id: tag |
| 61 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 62 | + |
| 63 | + - name: Set repository owner lowercase |
| 64 | + id: repo_owner |
| 65 | + env: |
| 66 | + REPO_OWNER: ${{ github.repository_owner }} |
| 67 | + run: echo "OWNER=$(echo "$REPO_OWNER" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT |
| 68 | + |
| 69 | + - name: Build and push container |
| 70 | + env: |
| 71 | + KO_DOCKER_REPO: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/waggle |
| 72 | + VERSION: ${{ steps.tag.outputs.VERSION }} |
| 73 | + CREATION_TIME: ${{ github.event.head_commit.timestamp }} |
| 74 | + run: | |
| 75 | + ko build \ |
| 76 | + --bare \ |
| 77 | + --sbom=spdx \ |
| 78 | + --platform=linux/amd64,linux/arm64 \ |
| 79 | + --tags $VERSION,latest \ |
| 80 | + ./cmd/waggle |
| 81 | +
|
| 82 | + - name: Install Cosign |
| 83 | + uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 |
| 84 | + |
| 85 | + - name: Sign Image with Cosign |
| 86 | + env: |
| 87 | + KO_DOCKER_REPO: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/waggle |
| 88 | + TAG_VERSION: ${{ steps.tag.outputs.VERSION }} |
| 89 | + GH_REF: ${{ github.ref }} |
| 90 | + run: | |
| 91 | + TAG=$(echo "$TAG_VERSION" | sed 's/+/_/g') |
| 92 | + cosign sign -y "$KO_DOCKER_REPO:$TAG" |
| 93 | + if [[ "$GH_REF" == refs/tags/* ]]; then |
| 94 | + cosign sign -y "$KO_DOCKER_REPO:latest" |
| 95 | + fi |
0 commit comments