Skip to content

Commit 2273b58

Browse files
workflows: replace softprops/action-gh-release with gh CLI
Supply-chain hardening: softprops/action-gh-release is a single-maintainer third-party action pinned to the mutable @v1 tag. Replacing it with the first-party `gh` CLI (pre-installed on GitHub-hosted runners, maintained by GitHub) removes that dependency from the release-upload path. Follow-up to #18, which migrated build-node-packages.yml. This migrates the remaining three workflows that still used the action: - build-node.yml - build-node-fibers.yml - build-node-openssl-fips.yml Each Upload step becomes: - view-or-create guard so the first matrix arm creates the release (and the second arm tolerates the race); - `gh release upload --clobber` for the asset (matches softprops's always-delete-then-upload behavior on name collision); - `gh release edit --title` to preserve softprops's behavior of always re-setting the release name on every upload. Each job also picks up `REPO: ${{ github.repository }}` in its env block for consistency with the pattern established in #18.
1 parent 56b09b1 commit 2273b58

3 files changed

Lines changed: 58 additions & 15 deletions

File tree

.github/workflows/build-node-fibers.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222

2323
env:
2424
NODE_VERSION: v20.18.3
25+
REPO: ${{ github.repository }}
2526

2627
steps:
2728
- name: Debug Matrix Values
@@ -78,10 +79,22 @@ jobs:
7879
tar -czf "$ARCHIVE_NAME" -C "$(dirname "$FIBERS_DIR")" "$(basename "$FIBERS_DIR")"
7980
8081
- name: Upload archive to release
81-
uses: softprops/action-gh-release@v1
82-
with:
83-
name: node-${{ env.NODE_VERSION }}-LATEST
84-
tag_name: node-${{ env.NODE_VERSION }}-release
85-
files: ${{ env.ARCHIVE_NAME }}
82+
# Use `gh release upload` (first-party GitHub CLI, pre-installed on runners)
83+
# instead of softprops/action-gh-release (one-maintainer third-party action).
84+
# The view-or-create guard is race-safe under the matrix and also handles the
85+
# workflow_dispatch case where the release may not yet exist. `--clobber`
86+
# overwrites an existing asset with the same name, matching softprops's
87+
# default. `gh release edit --title` preserves softprops's behavior of always
88+
# re-setting the release name on every upload.
8689
env:
8790
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: |
92+
set -euo pipefail
93+
TAG="node-${NODE_VERSION}-release"
94+
RELEASE_NAME="node-${NODE_VERSION}-LATEST"
95+
if ! gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
96+
gh release create "$TAG" --title "$RELEASE_NAME" --notes "" --repo "$REPO" \
97+
|| gh release view "$TAG" --repo "$REPO" >/dev/null
98+
fi
99+
gh release upload "$TAG" "$ARCHIVE_NAME" --clobber --repo "$REPO"
100+
gh release edit "$TAG" --title "$RELEASE_NAME" --repo "$REPO"

.github/workflows/build-node-openssl-fips.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
env:
4747
S3_BUCKET: your-bucket-name
4848
AWS_REGION: us-east-1
49+
REPO: ${{ github.repository }}
4950

5051
steps:
5152
- name: Checkout Node fork
@@ -148,10 +149,24 @@ jobs:
148149
path: artifacts/${{ env.NODE_ARCHIVE_LATEST }}
149150

150151
- name: Upload Node archive to release
151-
uses: softprops/action-gh-release@v1
152-
with:
153-
name: node-${{ env.NODE_VERSION }}-fips-static-LATEST
154-
tag_name: node-${{ env.NODE_VERSION }}-fips-static-release
155-
files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }}
152+
# Use `gh release upload` (first-party GitHub CLI, pre-installed on runners)
153+
# instead of softprops/action-gh-release (one-maintainer third-party action).
154+
# The view-or-create guard is race-safe under the matrix: if the sibling
155+
# job creates the release first, `gh release create` fails and the second
156+
# `gh release view` confirms the release now exists. `--clobber` overwrites
157+
# an existing asset with the same name, matching softprops's default. The
158+
# final `gh release edit --title` preserves softprops's behavior of always
159+
# re-setting the release name on every upload.
156160
env:
157161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162+
run: |
163+
set -euo pipefail
164+
TAG="node-${NODE_VERSION}-fips-static-release"
165+
RELEASE_NAME="node-${NODE_VERSION}-fips-static-LATEST"
166+
FILE="./artifacts/${NODE_ARCHIVE_LATEST}"
167+
if ! gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
168+
gh release create "$TAG" --title "$RELEASE_NAME" --notes "" --repo "$REPO" \
169+
|| gh release view "$TAG" --repo "$REPO" >/dev/null
170+
fi
171+
gh release upload "$TAG" "$FILE" --clobber --repo "$REPO"
172+
gh release edit "$TAG" --title "$RELEASE_NAME" --repo "$REPO"

.github/workflows/build-node.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
env:
2727
S3_BUCKET: your-bucket-name
2828
AWS_REGION: us-east-1
29+
REPO: ${{ github.repository }}
2930

3031
steps:
3132
- name: Checkout Node fork
@@ -97,10 +98,24 @@ jobs:
9798
path: artifacts/${{ env.NODE_ARCHIVE_LATEST }}
9899

99100
- name: Upload Node archive to release
100-
uses: softprops/action-gh-release@v1
101-
with:
102-
name: node-${{ env.NODE_VERSION }}-LATEST
103-
tag_name: node-${{ env.NODE_VERSION }}-release
104-
files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }}
101+
# Use `gh release upload` (first-party GitHub CLI, pre-installed on runners)
102+
# instead of softprops/action-gh-release (one-maintainer third-party action).
103+
# The view-or-create guard is race-safe under the matrix: if the sibling
104+
# job creates the release first, `gh release create` fails and the second
105+
# `gh release view` confirms the release now exists. `--clobber` overwrites
106+
# an existing asset with the same name, matching softprops's default. The
107+
# final `gh release edit --title` preserves softprops's behavior of always
108+
# re-setting the release name on every upload.
105109
env:
106110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
run: |
112+
set -euo pipefail
113+
TAG="node-${NODE_VERSION}-release"
114+
RELEASE_NAME="node-${NODE_VERSION}-LATEST"
115+
FILE="./artifacts/${NODE_ARCHIVE_LATEST}"
116+
if ! gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
117+
gh release create "$TAG" --title "$RELEASE_NAME" --notes "" --repo "$REPO" \
118+
|| gh release view "$TAG" --repo "$REPO" >/dev/null
119+
fi
120+
gh release upload "$TAG" "$FILE" --clobber --repo "$REPO"
121+
gh release edit "$TAG" --title "$RELEASE_NAME" --repo "$REPO"

0 commit comments

Comments
 (0)