Skip to content

Commit 0280c9b

Browse files
committed
Refactor GitHub Actions workflows to improve tag handling and signature verification for forks
Signed-off-by: Yun Pan <[email protected]>
1 parent 1a03476 commit 0280c9b

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

.github/workflows/api-release.yml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,41 @@ jobs:
2525
uses: actions/checkout@v4
2626
with:
2727
ref: ${{ github.ref }}
28-
path: src/github.com/containerd/containerd
28+
# check out to the repository root (workspace) so forks don't depend on upstream paths
29+
path: .
30+
fetch-depth: 0
31+
fetch-tags: true
2932

3033
- name: Check signature
3134
run: |
3235
releasever=${{ github.ref }}
3336
releasever="${releasever#refs/tags/}"
34-
TAGCHECK=$(git tag -v ${releasever} 2>&1 >/dev/null) ||
35-
echo "${TAGCHECK}" | grep -q "error" && {
37+
# Only enforce strict signature verification when running in the canonical upstream repository.
38+
# For forks, skip strict GPG verification because CI may not have the public keys.
39+
if [ "${{ github.repository }}" = "containerd/containerd" ]; then
40+
if ! git tag -v "${releasever}"; then
3641
echo "::error::tag ${releasever} is not a signed tag. Failing release process."
3742
exit 1
38-
} || {
39-
echo "Tag ${releasever} is signed."
40-
exit 0
41-
}
42-
working-directory: src/github.com/containerd/containerd
43+
fi
44+
echo "Tag ${releasever} is signed."
45+
else
46+
echo "Running in fork (${GITHUB_REPOSITORY}); skipping strict tag signature verification."
47+
fi
48+
working-directory: .
4349

4450
- name: Release content
4551
id: contentrel
4652
run: |
4753
RELEASEVER=${{ github.ref }}
4854
echo "stringver=${RELEASEVER#refs/tags/api/v}" >> $GITHUB_OUTPUT
4955
git tag -l ${RELEASEVER#refs/tags/} -n20000 | tail -n +3 | cut -c 5- >release-notes.md
50-
working-directory: src/github.com/containerd/containerd
56+
working-directory: .
5157

5258
- name: Save release notes
5359
uses: actions/upload-artifact@v4
5460
with:
5561
name: containerd-release-notes
56-
path: src/github.com/containerd/containerd/release-notes.md
62+
path: release-notes.md
5763

5864
release:
5965
name: Create containerd Release
@@ -68,7 +74,29 @@ jobs:
6874
uses: actions/download-artifact@v4
6975
with:
7076
path: builds
71-
- name: Create Release
77+
- name: Prepare release token check
78+
id: tokencheck
79+
run: |
80+
# Determine whether a RELEASE_TOKEN secret is provided; expose result as an output
81+
if [ -n "${{ secrets.RELEASE_TOKEN }}" ]; then
82+
echo "use_release_token=true" >> $GITHUB_OUTPUT
83+
else
84+
echo "use_release_token=false" >> $GITHUB_OUTPUT
85+
fi
86+
- name: Create Release (with RELEASE_TOKEN)
87+
if: ${{ steps.tokencheck.outputs.use_release_token == 'true' }}
88+
uses: softprops/action-gh-release@v2
89+
with:
90+
token: ${{ secrets.RELEASE_TOKEN }}
91+
fail_on_unmatched_files: true
92+
name: containerd API ${{ needs.check.outputs.stringver }}
93+
draft: false
94+
make_latest: false
95+
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
96+
body_path: ./builds/containerd-release-notes/release-notes.md
97+
98+
- name: Create Release (with GITHUB_TOKEN)
99+
if: ${{ steps.tokencheck.outputs.use_release_token == 'false' }}
72100
uses: softprops/action-gh-release@v2
73101
with:
74102
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,38 @@ jobs:
3232
uses: actions/checkout@v4
3333
with:
3434
ref: ${{ github.ref }}
35-
path: src/github.com/containerd/containerd
35+
path: .
3636

3737
- name: Check signature
3838
run: |
3939
releasever=${{ github.ref }}
4040
releasever="${releasever#refs/tags/}"
41-
TAGCHECK=$(git tag -v ${releasever} 2>&1 >/dev/null) ||
42-
echo "${TAGCHECK}" | grep -q "error" && {
41+
# Only enforce strict signature verification when running in the canonical upstream repository.
42+
# For forks, skip strict GPG verification because CI may not have the public keys.
43+
if [ "${{ github.repository }}" = "containerd/containerd" ]; then
44+
if ! git tag -v "${releasever}"; then
4345
echo "::error::tag ${releasever} is not a signed tag. Failing release process."
4446
exit 1
45-
} || {
46-
echo "Tag ${releasever} is signed."
47-
exit 0
48-
}
49-
working-directory: src/github.com/containerd/containerd
47+
fi
48+
echo "Tag ${releasever} is signed."
49+
else
50+
echo "Running in fork (${GITHUB_REPOSITORY}); skipping strict tag signature verification."
51+
fi
52+
working-directory: .
5053

5154
- name: Release content
5255
id: contentrel
5356
run: |
5457
RELEASEVER=${{ github.ref }}
5558
echo "stringver=${RELEASEVER#refs/tags/v}" >> $GITHUB_OUTPUT
5659
git tag -l ${RELEASEVER#refs/tags/} -n20000 | tail -n +3 | cut -c 5- >release-notes.md
57-
working-directory: src/github.com/containerd/containerd
60+
working-directory: .
5861

5962
- name: Save release notes
6063
uses: actions/upload-artifact@v4
6164
with:
6265
name: containerd-release-notes
63-
path: src/github.com/containerd/containerd/release-notes.md
66+
path: release-notes.md
6467

6568
build:
6669
name: Build Release Binaries
@@ -100,7 +103,7 @@ jobs:
100103
# See https://github.com/containerd/containerd/issues/5098 for the context.
101104
repository: ${{ github.repository }}
102105
ref: ${{ github.ref }}
103-
path: src/github.com/containerd/containerd
106+
path: .
104107

105108
- name: Setup buildx instance
106109
uses: docker/setup-buildx-action@v3
@@ -123,14 +126,14 @@ jobs:
123126
124127
# Remove symlinks since we don't want these in the release Artifacts
125128
find ./releases/ -maxdepth 1 -type l | xargs rm
126-
working-directory: src/github.com/containerd/containerd
129+
working-directory: .
127130
env:
128131
PLATFORM: ${{ matrix.dockerfile-platform }}
129132
- name: Save Artifacts
130133
uses: actions/upload-artifact@v4
131134
with:
132135
name: release-tars-${{env.PLATFORM_CLEAN}}
133-
path: src/github.com/containerd/containerd/releases/*.tar.gz*
136+
path: releases/*.tar.gz*
134137

135138
release:
136139
name: Create containerd Release

0 commit comments

Comments
 (0)