| 1 |
# |
| 2 |
# Copyright 2025 The Sigstore Authors. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
name: Release service builder container |
| 16 |
|
| 17 |
on: |
| 18 |
push: |
| 19 |
tags: |
| 20 |
- 'release/service-builder/v*' |
| 21 |
|
| 22 |
permissions: {} |
| 23 |
|
| 24 |
jobs: |
| 25 |
release: |
| 26 |
name: Release services container image |
| 27 |
runs-on: ubuntu-latest |
| 28 |
|
| 29 |
permissions: |
| 30 |
id-token: write # needed to sign build provenance |
| 31 |
contents: read |
| 32 |
packages: write # needed to upload to GitHub Packages |
| 33 |
attestations: write # needed to persist attestation |
| 34 |
|
| 35 |
env: |
| 36 |
TAG: ${{ github.ref_name }} |
| 37 |
REGISTRY: ghcr.io |
| 38 |
IMAGE_NO_TAG: ghcr.io/${{ github.repository }}-service-builder |
| 39 |
|
| 40 |
steps: |
| 41 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 42 |
with: |
| 43 |
persist-credentials: false |
| 44 |
|
| 45 |
- name: Calculate tag and image_ref |
| 46 |
run: | |
| 47 |
tag="${TAG#"release/service-builder/v"}" |
| 48 |
echo "IMAGE_REF=${IMAGE_NO_TAG}:$tag" >> $GITHUB_ENV |
| 49 |
|
| 50 |
- name: Log into ghcr.io |
| 51 |
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
| 52 |
with: |
| 53 |
registry: ${{ env.REGISTRY }} |
| 54 |
username: ${{ github.repository_owner }} |
| 55 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 56 |
|
| 57 |
- name: Build services container |
| 58 |
run: make services-image |
| 59 |
|
| 60 |
- name: Tag image |
| 61 |
run: docker tag protoc-services ${IMAGE_REF} |
| 62 |
|
| 63 |
- name: Push image |
| 64 |
run: docker push ${IMAGE_REF} |
| 65 |
|
| 66 |
- name: Get image digest |
| 67 |
run: | |
| 68 |
digest=$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REF}) |
| 69 |
image_digest=$(echo $digest | cut -d"@" -f2) |
| 70 |
echo "IMAGE_DIGEST=$image_digest" >> "$GITHUB_ENV" |
| 71 |
|
| 72 |
- name: Generate artifact attestation |
| 73 |
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 |
| 74 |
with: |
| 75 |
subject-name: ${{ env.IMAGE_NO_TAG }} |
| 76 |
subject-digest: ${{ env.IMAGE_DIGEST }} |
| 77 |
push-to-registry: true |
| 78 |
|