Skip to content

Commit 3d72da6

Browse files
committed
prevent rerun if nothing has changed
1 parent 7ceeb11 commit 3d72da6

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,37 @@ env:
1717
ELECTRON_VERSION: ${{ inputs.electron_version || '32.2.7' }}
1818

1919
jobs:
20+
compute-shasum:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
26+
- name: Compute Sorted SHASUM
27+
id: compute-shasum
28+
run: |
29+
# Generate SHASUM for all relevant files and sort them
30+
chmod +x ./create-shasum.sh
31+
./create-shasum.sh
32+
33+
# Output the current SHASUM for the environment
34+
echo "shasum256save=$(cat sha256.txt)" >> $GITHUB_ENV
35+
36+
- name: Check for Existing SHASUM
37+
id: check-shasum
38+
run: |
39+
if [ -f ./.last-shasum ]; then
40+
echo "Previous SHASUM exists."
41+
diff sha256.txt ./.last-shasum > /dev/null || exit 1
42+
else
43+
echo "No previous SHASUM found."
44+
exit 1
45+
fi
46+
continue-on-error: true
47+
2048
build:
49+
needs: compute-shasum
50+
if: failure()
2151
strategy:
2252
matrix:
2353
os: [ubuntu-latest, windows-latest, macOS-latest]
@@ -85,9 +115,10 @@ jobs:
85115
86116
- name: Commit Updated Version
87117
run: |
118+
echo "${{ env.shasum256save }}" > .last-shasum
88119
git config user.name "github-actions"
89120
git config user.email "actions@github.com"
90-
git add package.json
121+
git add package.json .last-shasum
91122
git commit -m "chore: update version to ${{ env.new_version }}"
92123
env:
93124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -105,17 +136,21 @@ jobs:
105136
merge-multiple: true
106137

107138
- name: Create GitHub Release
108-
uses: actions/create-release@v1
139+
uses: softprops/action-gh-release@v2
109140
with:
110141
tag_name: "v${{ env.new_version }}"
111-
release_name: "Release v${{ env.new_version }}"
142+
name: "Release v${{ env.new_version }}"
112143
body: |
113144
## Changes
114145
- Automatic version bump to v${{ env.new_version }}.
146+
- Automatic prebuilds for all platforms and architectures that use the Node.js in version ${{ env.NODE_VERSION }} and Electron in version ${{ env.ELECTRON_VERSION }}.
115147
draft: false
116148
prerelease: false
117-
env:
118-
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
149+
token: ${{ secrets.PAT_TOKEN }}
150+
make_latest: true
151+
files: |
152+
prebuilds/*
153+
.last-shasum
119154
120155
- name: Publish to npm
121156
uses: actions/setup-node@v4

create-shasum.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
find ./src -type f -print0 | sort -z | xargs -0 sha256sum > current-shasum.txt
4+
sha256sum ./build-* ./binding.gyp >> current-shasum.txt || true
5+
echo "ZZZZ:ENV:Node:${NODE_VERSION},Electron:${ELECTRON_VERSION}" >> current-shasum.txt
6+
7+
sort current-shasum.txt -o current-shasum.txt
8+
9+
# Generate the final SHASUM for comparison
10+
sha256sum current-shasum.txt | awk '{print $1}' > sha256.txt

0 commit comments

Comments
 (0)