Skip to content

Commit 4fb5871

Browse files
committed
update workflows
1 parent f7ecf72 commit 4fb5871

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

.github/workflows/binary-build.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
name: Binary Build & Release
22

33
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]
108

119
jobs:
1210
build:
13-
name: Build Binary
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1412
runs-on: ubuntu-latest
15-
outputs:
16-
checksum: ${{ steps.create_checksum.outputs.checksum }}
17-
version: ${{ steps.get_version.outputs.version }}
1813
steps:
1914
- name: Checkout Repo
2015
uses: actions/checkout@v4
@@ -33,39 +28,49 @@ jobs:
3328
- name: Install Dependencies
3429
run: pnpm install
3530

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
4333
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
4850
4951
- name: Build Binary (macOS)
52+
if: steps.check_cli.outputs.should_build == 'true'
5053
run: pnpm --filter "git-intent" pkg:build:macos
5154

5255
- name: Create Checksum
56+
if: steps.check_cli.outputs.should_build == 'true'
5357
id: create_checksum
5458
run: |
5559
cd packages/cli/build
5660
ls -la
5761
cp git-intent-macos git-intent
58-
VERSION="${{ steps.get_version.outputs.version }}"
62+
VERSION="${{ steps.check_cli.outputs.version }}"
5963
tar -czf git-intent-$VERSION-darwin-amd64.tar.gz git-intent
6064
CHECKSUM=$(shasum -a 256 git-intent-$VERSION-darwin-amd64.tar.gz | awk '{print $1}')
6165
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
6266
echo "::notice::Binary checksum: $CHECKSUM"
6367
6468
- name: Upload Binary to GitHub Release
69+
if: steps.check_cli.outputs.should_build == 'true'
6570
env:
6671
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6772
run: |
68-
VERSION="${{ steps.get_version.outputs.version }}"
73+
VERSION="${{ steps.check_cli.outputs.version }}"
6974
# add binary to existing release
7075
gh release upload v$VERSION packages/cli/build/git-intent-$VERSION-darwin-amd64.tar.gz
7176

.github/workflows/release.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,4 @@ jobs:
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
58-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59-
60-
# Dispatch to other workflows if published
61-
- name: Trigger Binary Build
62-
if: steps.changesets.outputs.published == 'true'
63-
uses: peter-evans/repository-dispatch@v3
64-
with:
65-
token: ${{ secrets.GITHUB_TOKEN }}
66-
event-type: trigger-binary-build
67-
client-payload: '{"version": "${{ steps.changesets.outputs.version }}"}'
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)