Skip to content

Commit 41fc12f

Browse files
add dry run mode for testing on non-main branches
1 parent 86d462c commit 41fc12f

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/release-binaries.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Release Binaries
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, install-sh]
66
paths:
77
- 'package.json'
8+
- '.github/workflows/release-binaries.yml'
9+
- 'nfpm.yaml'
810
workflow_dispatch:
911

1012
permissions:
@@ -17,6 +19,7 @@ jobs:
1719
outputs:
1820
version: ${{ steps.check.outputs.version }}
1921
released: ${{ steps.check.outputs.released }}
22+
dry_run: ${{ steps.check.outputs.dry_run }}
2023
steps:
2124
- name: Checkout repository
2225
uses: actions/checkout@v4
@@ -28,10 +31,18 @@ jobs:
2831
run: |
2932
VERSION=$(node -p "require('./package.json').version")
3033
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
31-
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
34+
35+
# Dry run on non-main branches
36+
if [ "${{ github.ref_name }}" != "main" ]; then
37+
echo "dry_run=true" >> "$GITHUB_OUTPUT"
38+
echo "released=false" >> "$GITHUB_OUTPUT"
39+
echo "Dry run on branch ${{ github.ref_name }} — will build but not release"
40+
elif git rev-parse "v$VERSION" >/dev/null 2>&1; then
41+
echo "dry_run=false" >> "$GITHUB_OUTPUT"
3242
echo "released=true" >> "$GITHUB_OUTPUT"
3343
echo "v$VERSION already released — skipping"
3444
else
45+
echo "dry_run=false" >> "$GITHUB_OUTPUT"
3546
echo "released=false" >> "$GITHUB_OUTPUT"
3647
echo "New version detected: v$VERSION"
3748
fi
@@ -154,7 +165,20 @@ jobs:
154165
sha256sum * > checksums.txt
155166
cat checksums.txt
156167
168+
- name: Summary (dry run)
169+
if: needs.check-version.outputs.dry_run == 'true'
170+
run: |
171+
echo "## Dry Run — Release v${{ needs.check-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
172+
echo "" >> $GITHUB_STEP_SUMMARY
173+
echo "All artifacts built and packaged successfully:" >> $GITHUB_STEP_SUMMARY
174+
echo '```' >> $GITHUB_STEP_SUMMARY
175+
ls -lh release/ >> $GITHUB_STEP_SUMMARY
176+
echo '```' >> $GITHUB_STEP_SUMMARY
177+
echo "" >> $GITHUB_STEP_SUMMARY
178+
echo "**No release created — this is a dry run on branch \`${{ github.ref_name }}\`.**" >> $GITHUB_STEP_SUMMARY
179+
157180
- name: Generate release notes
181+
if: needs.check-version.outputs.dry_run != 'true'
158182
run: |
159183
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
160184
if [ -n "$PREV_TAG" ]; then
@@ -164,6 +188,7 @@ jobs:
164188
fi
165189
166190
- name: Create tag and GitHub release
191+
if: needs.check-version.outputs.dry_run != 'true'
167192
env:
168193
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169194
run: |

0 commit comments

Comments
 (0)