1
1
name : Binary Build & Release
2
2
3
3
on :
4
- repository_dispatch :
5
- types : [trigger-binary-build]
6
-
7
- permissions :
8
- contents : write
9
- packages : write
4
+ workflow_run :
5
+ workflows : ["Release"]
6
+ types : [completed]
7
+ branches : [main]
10
8
11
9
jobs :
12
10
build :
13
- name : Build Binary
11
+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
14
12
runs-on : ubuntu-latest
15
- outputs :
16
- checksum : ${{ steps.create_checksum.outputs.checksum }}
17
- version : ${{ steps.get_version.outputs.version }}
18
13
steps :
19
14
- name : Checkout Repo
20
15
uses : actions/checkout@v4
@@ -33,39 +28,49 @@ jobs:
33
28
- name : Install Dependencies
34
29
run : pnpm install
35
30
36
- - name : Setup Git User
37
- run : |
38
- git config --global user.email "[email protected] "
39
- git config --global user.name "Juhyeok Kang"
40
-
41
- - name : Get Version
42
- id : get_version
31
+ - name : Check if CLI package was published
32
+ id : check_cli
43
33
run : |
44
- echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
45
-
46
- - name : Build Packages
47
- run : pnpm build
34
+ # Get the latest tag
35
+ git fetch --tags
36
+ LATEST_TAG=$(git describe --tags --abbrev=0)
37
+
38
+ # Check if CLI package version matches the tag
39
+ CLI_VERSION=$(node -p "require('./packages/cli/package.json').version")
40
+ TAG_VERSION=${LATEST_TAG#v}
41
+
42
+ if [ "$CLI_VERSION" = "$TAG_VERSION" ]; then
43
+ echo "CLI package was published in this release, building binary"
44
+ echo "should_build=true" >> $GITHUB_OUTPUT
45
+ echo "version=$CLI_VERSION" >> $GITHUB_OUTPUT
46
+ else
47
+ echo "CLI package was not published in this release, skipping binary build"
48
+ echo "should_build=false" >> $GITHUB_OUTPUT
49
+ fi
48
50
49
51
- name : Build Binary (macOS)
52
+ if : steps.check_cli.outputs.should_build == 'true'
50
53
run : pnpm --filter "git-intent" pkg:build:macos
51
54
52
55
- name : Create Checksum
56
+ if : steps.check_cli.outputs.should_build == 'true'
53
57
id : create_checksum
54
58
run : |
55
59
cd packages/cli/build
56
60
ls -la
57
61
cp git-intent-macos git-intent
58
- VERSION="${{ steps.get_version .outputs.version }}"
62
+ VERSION="${{ steps.check_cli .outputs.version }}"
59
63
tar -czf git-intent-$VERSION-darwin-amd64.tar.gz git-intent
60
64
CHECKSUM=$(shasum -a 256 git-intent-$VERSION-darwin-amd64.tar.gz | awk '{print $1}')
61
65
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
62
66
echo "::notice::Binary checksum: $CHECKSUM"
63
67
64
68
- name : Upload Binary to GitHub Release
69
+ if : steps.check_cli.outputs.should_build == 'true'
65
70
env :
66
71
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67
72
run : |
68
- VERSION="${{ steps.get_version .outputs.version }}"
73
+ VERSION="${{ steps.check_cli .outputs.version }}"
69
74
# add binary to existing release
70
75
gh release upload v$VERSION packages/cli/build/git-intent-$VERSION-darwin-amd64.tar.gz
71
76
0 commit comments