Skip to content

Commit 8b913d8

Browse files
authored
Merge pull request #147 from zircote/fix/release-workflows
fix(ci): repair three release-triggered workflow failures
2 parents 9f4b93a + 1a79570 commit 8b913d8

File tree

4 files changed

+103
-53
lines changed

4 files changed

+103
-53
lines changed

.github/workflows/changelog.yml

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,75 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout repository
20-
# v6.0.2
20+
# yamllint disable-line rule:line-length
2121
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2222
with:
2323
fetch-depth: 0
2424

2525
- name: Generate changelog
26-
# v4.5.0
27-
uses: orhun/git-cliff-action@c93ef52f3d0ddcdcc9bd5447d98d458a11cd4f72
26+
# yamllint disable-line rule:line-length
27+
uses: orhun/git-cliff-action@c93ef52f3d0ddcdcc9bd5447d98d458a11cd4f72 # v4.5.0
2828
with:
2929
config: cliff.toml
3030
args: --verbose
3131
env:
3232
OUTPUT: CHANGELOG.md
3333

34-
- name: Commit changelog
34+
- name: Check for changes
35+
id: diff
36+
run: |
37+
if git diff --quiet CHANGELOG.md 2>/dev/null; then
38+
echo "changed=false" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "changed=true" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
- name: Create pull request
44+
if: steps.diff.outputs.changed == 'true'
3545
env:
3646
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3747
TAG_NAME: ${{ github.ref_name }}
3848
run: |
39-
if git diff --quiet CHANGELOG.md 2>/dev/null; then
40-
echo "No changes to commit"
41-
exit 0
49+
BRANCH="chore/changelog-${TAG_NAME}"
50+
51+
# Reuse existing remote branch if it already exists; otherwise create it.
52+
if git ls-remote --exit-code origin "${BRANCH}" >/dev/null 2>&1; then
53+
echo "Branch ${BRANCH} already exists on origin; checking it out."
54+
git fetch origin "${BRANCH}:${BRANCH}"
55+
git checkout "${BRANCH}"
56+
else
57+
echo "Creating new branch ${BRANCH}."
58+
git checkout -b "${BRANCH}"
4259
fi
4360
44-
REPO="${{ github.repository }}"
45-
API_PATH="repos/${REPO}/contents/CHANGELOG.md"
46-
CONTENT=$(base64 -i CHANGELOG.md)
47-
SHA=$(gh api "$API_PATH" \
48-
--jq '.sha' 2>/dev/null || echo "")
49-
50-
MSG="docs: update CHANGELOG.md for ${TAG_NAME}"
51-
ARGS=(
52-
-f "message=${MSG}"
53-
-f "content=${CONTENT}"
54-
-f "branch=main"
55-
)
56-
if [ -n "$SHA" ]; then
57-
ARGS+=(-f "sha=${SHA}")
61+
git add CHANGELOG.md
62+
git config user.name "github-actions[bot]"
63+
git config user.email "github-actions[bot]@users.noreply.github.com"
64+
65+
# Only commit and push if there are staged changes.
66+
if git diff --cached --quiet; then
67+
echo "No changes to commit on branch ${BRANCH}; skipping commit and push."
68+
else
69+
git commit -m "docs: update CHANGELOG.md for ${TAG_NAME}"
70+
git push origin "${BRANCH}"
5871
fi
5972
60-
gh api "$API_PATH" \
61-
--method PUT "${ARGS[@]}"
62-
echo "Changelog updated via GitHub API"
73+
TITLE="docs: update CHANGELOG.md for ${TAG_NAME}"
74+
BODY="Auto-generated changelog update for ${TAG_NAME}."
75+
76+
# Reuse existing open PR for this branch if present; otherwise create a new one.
77+
PR_NUMBER="$(gh pr list --head "${BRANCH}" --state open --json number --jq '.[0].number' || true)"
78+
79+
if [ -z "${PR_NUMBER}" ]; then
80+
echo "No existing pull request for ${BRANCH}; creating a new one."
81+
gh pr create \
82+
--title "${TITLE}" \
83+
--body "${BODY}" \
84+
--base main \
85+
--head "${BRANCH}"
86+
else
87+
echo "Pull request #${PR_NUMBER} already exists for ${BRANCH}; updating title and body."
88+
gh pr edit "${PR_NUMBER}" \
89+
--title "${TITLE}" \
90+
--body "${BODY}"
91+
fi

.github/workflows/sbom.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ jobs:
4848
GH_TOKEN: ${{ github.token }}
4949
TAG_NAME: ${{ github.event.release.tag_name }}
5050
run: |
51-
gh release upload "${TAG_NAME}" nsip-sbom-spdx.json
51+
gh release upload "${TAG_NAME}" nsip-sbom-spdx.json \
52+
--clobber
Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
1+
---
22
name: Signed Releases
33

4-
on:
5-
release:
6-
types: [published]
4+
"on":
5+
workflow_run:
6+
workflows: ["Release"]
7+
types: [completed]
78

89
permissions:
910
contents: write
@@ -13,17 +14,27 @@ jobs:
1314
sign-assets:
1415
name: Sign Release Assets
1516
runs-on: ubuntu-latest
16-
17+
if: >-
18+
github.event.workflow_run.conclusion == 'success'
19+
&& startsWith(github.event.workflow_run.head_branch, 'v')
1720
steps:
21+
- name: Get tag name
22+
id: tag
23+
env:
24+
TAG: ${{ github.event.workflow_run.head_branch }}
25+
run: echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
26+
1827
- name: Install Cosign
19-
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
28+
# yamllint disable-line rule:line-length
29+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
2030

2131
- name: Download release assets
2232
env:
2333
GH_TOKEN: ${{ github.token }}
34+
TAG: ${{ steps.tag.outputs.tag }}
2435
run: |
25-
gh release download ${{ github.event.release.tag_name }} \
26-
--repo ${{ github.repository }} \
36+
gh release download "${TAG}" \
37+
--repo "${{ github.repository }}" \
2738
--pattern '*'
2839
2940
- name: Sign assets with Cosign
@@ -48,40 +59,49 @@ jobs:
4859
- name: Upload signatures
4960
env:
5061
GH_TOKEN: ${{ github.token }}
62+
TAG: ${{ steps.tag.outputs.tag }}
5163
run: |
52-
gh release upload ${{ github.event.release.tag_name }} \
53-
--repo ${{ github.repository }} \
64+
gh release upload "${TAG}" \
65+
--repo "${{ github.repository }}" \
5466
--clobber \
5567
*.sig SHA256SUMS SHA512SUMS
5668
5769
- name: Update release notes
5870
env:
5971
GH_TOKEN: ${{ github.token }}
72+
TAG: ${{ steps.tag.outputs.tag }}
73+
# yamllint disable rule:line-length
6074
run: |
61-
cat >> release_notes.md << 'NOTES'
62-
75+
EXISTING=$(gh release view "${TAG}" \
76+
--repo "${{ github.repository }}" \
77+
--json body -q .body)
78+
79+
printf '%s\n' "$EXISTING" > release_notes.md
80+
81+
cat <<'NOTES' >> release_notes.md
6382
## Verification
64-
83+
6584
All release assets are signed with [Sigstore Cosign](https://github.com/sigstore/cosign).
66-
85+
6786
### Verify signatures:
68-
69-
```bash
87+
88+
\`\`\`bash
7089
# Install cosign
7190
brew install cosign # or download from GitHub
72-
91+
7392
# Verify asset signature
74-
cosign verify-blob \
75-
--signature <file>.sig \
76-
--certificate-identity-regexp=".*" \
77-
--certificate-oidc-issuer-regexp=".*" \
93+
cosign verify-blob \\
94+
--signature <file>.sig \\
95+
--certificate-identity-regexp=".*" \\
96+
--certificate-oidc-issuer-regexp=".*" \\
7897
<file>
79-
98+
8099
# Verify checksums
81100
sha256sum --check SHA256SUMS
82-
```
101+
\`\`\`
83102
NOTES
84-
85-
gh release edit ${{ github.event.release.tag_name }} \
86-
--repo ${{ github.repository }} \
103+
104+
gh release edit "${TAG}" \
105+
--repo "${{ github.repository }}" \
87106
--notes-file release_notes.md
107+
# yamllint enable rule:line-length

crates/mcp/oauth/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub struct TokenResponse {
5757

5858
/// Generate an opaque refresh token.
5959
fn generate_refresh_token() -> String {
60-
use rand::Rng as _;
61-
let bytes: [u8; 32] = rand::rng().random();
60+
let mut bytes = [0u8; 32];
61+
rand::fill(&mut bytes);
6262
base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(bytes)
6363
}
6464

0 commit comments

Comments
 (0)