1+ ` ` ` yaml
12name: GrandNode Docker Release
23
34on:
45 push:
56 tags:
67 - '*.*.*'
78
9+ workflow_dispatch:
10+ inputs:
11+ version:
12+ description: 'Docker image version, for example 2.3.0'
13+ required: true
14+ type: string
15+
816permissions:
917 contents: read
1018 packages: write
@@ -25,112 +33,22 @@ jobs:
2533 with:
2634 fetch-depth: 0
2735
28- - name : Validate release tag
36+ - name: Determine release version
2937 shell: bash
3038 run: |
31- VERSION="${GITHUB_REF_NAME}"
39+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
40+ VERSION="${{ inputs.version }}"
41+ else
42+ VERSION="${GITHUB_REF_NAME}"
43+ fi
3244
3345 if [[ ! "$VERSION" =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
34- echo "Invalid release tag : $VERSION"
46+ echo "Invalid release version : $VERSION"
3547 echo "Expected format: X.Y.Z, for example 2.3.0"
3648 exit 1
3749 fi
3850
3951 echo "VERSION=$VERSION" >> "$GITHUB_ENV"
4052
4153 echo "Release version: $VERSION"
42-
43- - name : Login to GHCR
44- uses : docker/login-action@v4
45- with :
46- registry : ${{ env.REGISTRY }}
47- username : ${{ github.actor }}
48- password : ${{ secrets.GITHUB_TOKEN }}
49-
50- - name : Set up Docker Buildx
51- uses : docker/setup-buildx-action@v4
52-
53- - name : Build and push Docker image
54- id : build
55- uses : docker/build-push-action@v7
56- with :
57- context : .
58- push : true
59-
60- tags : |
61- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
62-
63- labels : |
64- org.opencontainers.image.source=https://github.com/grandnode/grandnode2
65- org.opencontainers.image.version=${{ env.VERSION }}
66- org.opencontainers.image.revision=${{ github.sha }}
67- org.opencontainers.image.description=GrandNode Docker release ${{ env.VERSION }}
68-
69- # BuildKit generates both attestations during the build.
70- sbom : true
71- provenance : mode=max
72-
73- # GitHub Actions cache
74- cache-from : type=gha
75- cache-to : type=gha,mode=max
76-
77- - name : Install Cosign
78- uses : sigstore/cosign-installer@v4.1.2
79-
80- - name : Show release information
81- run : |
82- echo "Version:"
83- echo "${VERSION}"
84-
85- echo "Git tag:"
86- echo "${GITHUB_REF_NAME}"
87-
88- echo "Git commit:"
89- echo "${GITHUB_SHA}"
90-
91- echo "Docker image:"
92- echo "${REGISTRY}/${IMAGE_NAME}:${VERSION}"
93-
94- echo "Docker digest:"
95- echo "${{ steps.build.outputs.digest }}"
96-
97- - name : Cosign keyless sign
98- env :
99- IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
100- DIGEST : ${{ steps.build.outputs.digest }}
101- run : |
102- cosign sign \
103- --yes \
104- "${IMAGE}@${DIGEST}"
105-
106- - name : Cosign keyless verify
107- env :
108- IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
109- DIGEST : ${{ steps.build.outputs.digest }}
110- run : |
111- cosign verify \
112- "${IMAGE}@${DIGEST}" \
113- --certificate-identity="https://github.com/grandnode/grandnode2/.github/workflows/docker-release.yml@refs/tags/${VERSION}" \
114- --certificate-oidc-issuer="https://token.actions.githubusercontent.com"
115-
116- - name : Verify SBOM attestation
117- env :
118- IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
119- DIGEST : ${{ steps.build.outputs.digest }}
120- run : |
121- cosign verify-attestation \
122- "${IMAGE}@${DIGEST}" \
123- --type spdx \
124- --certificate-identity="https://github.com/grandnode/grandnode2/.github/workflows/docker-release.yml@refs/tags/${VERSION}" \
125- --certificate-oidc-issuer="https://token.actions.githubusercontent.com"
126-
127- - name : Verify provenance attestation
128- env :
129- IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
130- DIGEST : ${{ steps.build.outputs.digest }}
131- run : |
132- cosign verify-attestation \
133- "${IMAGE}@${DIGEST}" \
134- --type slsaprovenance \
135- --certificate-identity="https://github.com/grandnode/grandnode2/.github/workflows/docker-release.yml@refs/tags/${VERSION}" \
136- --certificate-oidc-issuer="https://token.actions.githubusercontent.com"
54+ ` ` `
0 commit comments