|
8 | 8 |
|
9 | 9 | permissions: |
10 | 10 | contents: write |
| 11 | + actions: write |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | extract-version: |
@@ -36,77 +37,36 @@ jobs: |
36 | 37 |
|
37 | 38 | - name: Check if release exists |
38 | 39 | id: check |
| 40 | + env: |
| 41 | + GH_TOKEN: ${{ github.token }} |
39 | 42 | run: | |
40 | 43 | VERSION="${{ steps.version.outputs.version }}" |
41 | | - if git rev-parse "v$VERSION" >/dev/null 2>&1; then |
42 | | - echo "Tag v$VERSION already exists, skipping release" |
| 44 | +
|
| 45 | + # Check if GitHub release exists |
| 46 | + if gh release view "v$VERSION" >/dev/null 2>&1; then |
| 47 | + echo "Release v$VERSION already exists, skipping release" |
43 | 48 | echo "should_release=false" >> $GITHUB_OUTPUT |
44 | | - else |
45 | | - echo "Tag v$VERSION does not exist, proceeding with release" |
46 | | - echo "should_release=true" >> $GITHUB_OUTPUT |
| 49 | + exit 0 |
47 | 50 | fi |
48 | 51 |
|
| 52 | + echo "Release v$VERSION does not exist, proceeding with release" |
| 53 | + echo "should_release=true" >> $GITHUB_OUTPUT |
| 54 | +
|
49 | 55 | ci: |
50 | 56 | name: Run CI |
51 | 57 | needs: extract-version |
52 | 58 | if: needs.extract-version.outputs.should_release == 'true' |
53 | 59 | uses: ./.github/workflows/ci.yml |
54 | 60 |
|
55 | 61 | build: |
56 | | - name: Build ${{ matrix.goos }}-${{ matrix.goarch }} |
| 62 | + name: Build |
57 | 63 | needs: [extract-version, ci] |
58 | 64 | if: needs.extract-version.outputs.should_release == 'true' |
59 | | - runs-on: ubuntu-latest |
60 | | - strategy: |
61 | | - matrix: |
62 | | - include: |
63 | | - - goos: linux |
64 | | - goarch: amd64 |
65 | | - - goos: linux |
66 | | - goarch: arm64 |
67 | | - - goos: darwin |
68 | | - goarch: amd64 |
69 | | - - goos: darwin |
70 | | - goarch: arm64 |
71 | | - - goos: windows |
72 | | - goarch: amd64 |
73 | | - |
74 | | - steps: |
75 | | - - name: Checkout code |
76 | | - uses: actions/checkout@v4 |
77 | | - |
78 | | - - name: Set up Go |
79 | | - uses: actions/setup-go@v5 |
80 | | - with: |
81 | | - go-version: '1.25.1' |
82 | | - cache: true |
83 | | - |
84 | | - - name: Build binary |
85 | | - env: |
86 | | - GOOS: ${{ matrix.goos }} |
87 | | - GOARCH: ${{ matrix.goarch }} |
88 | | - CGO_ENABLED: 0 |
89 | | - run: | |
90 | | - VERSION="${{ needs.extract-version.outputs.version }}" |
91 | | - EXT="" |
92 | | - [ "$GOOS" = "windows" ] && EXT=".exe" |
93 | | - BINARY_NAME="sym-$GOOS-$GOARCH$EXT" |
94 | | -
|
95 | | - go build \ |
96 | | - -ldflags "-s -w -X main.Version=$VERSION" \ |
97 | | - -trimpath \ |
98 | | - -o "$BINARY_NAME" \ |
99 | | - ./cmd/sym |
100 | | -
|
101 | | - echo "Built $BINARY_NAME" |
102 | | -
|
103 | | - - name: Upload artifact |
104 | | - uses: actions/upload-artifact@v4 |
105 | | - with: |
106 | | - name: sym-${{ matrix.goos }}-${{ matrix.goarch }} |
107 | | - path: sym-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} |
108 | | - if-no-files-found: error |
109 | | - retention-days: 1 |
| 65 | + uses: ./.github/workflows/build.yml |
| 66 | + with: |
| 67 | + version: ${{ needs.extract-version.outputs.version }} |
| 68 | + upload-artifacts: true |
| 69 | + retention-days: 1 |
110 | 70 |
|
111 | 71 | release: |
112 | 72 | name: Create GitHub Release |
|
126 | 86 | - name: Prepare release assets |
127 | 87 | run: | |
128 | 88 | mkdir -p release-assets |
129 | | - find artifacts -type f -name 'sym-*' -exec mv {} release-assets/ \; |
| 89 | + find artifacts -type f \( -name 'sym-darwin-*' -o -name 'sym-linux-*' -o -name 'sym-windows-*' \) -exec mv {} release-assets/ \; |
130 | 90 |
|
131 | 91 | # Verify binary count |
132 | 92 | BINARY_COUNT=$(ls -1 release-assets/ | wc -l) |
@@ -172,10 +132,13 @@ jobs: |
172 | 132 | - name: Copy binaries to npm package |
173 | 133 | run: | |
174 | 134 | mkdir -p npm/bin |
175 | | - find artifacts -type f -name 'sym-*' -exec cp {} npm/bin/ \; |
| 135 | + find artifacts -type f \( -name 'sym-*' ! -name '*.js' \) -exec cp {} npm/bin/ \; |
| 136 | +
|
| 137 | + # Set executable permissions for Unix binaries |
| 138 | + chmod +x npm/bin/sym-darwin-* npm/bin/sym-linux-* 2>/dev/null || true |
176 | 139 |
|
177 | 140 | # Verify binary count |
178 | | - BINARY_COUNT=$(find npm/bin -name 'sym-*' -type f | wc -l) |
| 141 | + BINARY_COUNT=$(find npm/bin -name 'sym-*' -type f ! -name '*.js' | wc -l) |
179 | 142 | echo "Found $BINARY_COUNT binaries in npm/bin/" |
180 | 143 |
|
181 | 144 | if [ "$BINARY_COUNT" -ne 5 ]; then |
|
0 commit comments