Skip to content

Commit 3660dec

Browse files
authored
[Actions] Modify Action for PR branch
2 parents b92e46f + 8ca4acd commit 3660dec

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

.github/workflows/main.yml

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15-
build-rust:
16-
15+
build-and-test:
16+
name: Build & Test
1717
runs-on: ${{ matrix.os }}
1818
timeout-minutes: 30
1919
strategy:
@@ -56,6 +56,49 @@ jobs:
5656
run: cargo build --verbose
5757
- name: Run tests
5858
run: cargo test --verbose
59+
60+
build-release:
61+
name: Build Release
62+
needs: [build-and-test]
63+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
64+
runs-on: ${{ matrix.os }}
65+
timeout-minutes: 30
66+
strategy:
67+
# ensures each build runs even if one fails
68+
fail-fast: false
69+
matrix:
70+
include:
71+
- os: ubuntu-latest
72+
target: x86_64-unknown-linux-gnu
73+
artifact_name: log2src
74+
asset_name: log2src-${{ github.ref_name }}-linux-x64
75+
- os: macos-latest
76+
target: x86_64-apple-darwin
77+
artifact_name: log2src
78+
asset_name: log2src-${{ github.ref_name }}-macos-x64
79+
- os: macos-latest
80+
target: aarch64-apple-darwin
81+
artifact_name: log2src
82+
asset_name: log2src-${{ github.ref_name }}-macos-arm64
83+
- os: windows-latest
84+
target: x86_64-pc-windows-msvc
85+
artifact_name: log2src.exe
86+
asset_name: log2src-${{ github.ref_name }}-windows-x64
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Install Rust toolchain
92+
uses: actions-rs/toolchain@v1
93+
with:
94+
toolchain: stable
95+
target: ${{ matrix.target }}
96+
override: true
97+
98+
- name: Setup cross-compilation for ARM64
99+
if: matrix.target == 'aarch64-apple-darwin'
100+
run: rustup target add aarch64-apple-darwin
101+
59102
- name: Build release binary
60103
run: cargo build --release --target ${{ matrix.target }}
61104

@@ -82,7 +125,8 @@ jobs:
82125

83126
vscode-extension:
84127
name: Build VS Code Extensions
85-
needs: [build-rust]
128+
needs: [build-release]
129+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
86130
runs-on: ubuntu-latest
87131

88132
steps:
@@ -135,23 +179,23 @@ jobs:
135179
working-directory: editors/code
136180
run: |
137181
REF_NAME="${{ github.ref_name }}"
138-
echo "EXT_VERSION=${REF_NAME#v}" >> $GITHUB_ENV
182+
VERSION=${REF_NAME#v}
139183
# Update version in package.json
140-
jq '.version = "'${REF_NAME#v}'"' package.json > package.json.new
184+
jq '.version = "'$VERSION'"' package.json > package.json.new
141185
mv package.json.new package.json
142186
pnpm vsce package --no-dependencies
143187
144188
- name: Upload VS Code extension
145189
if: startsWith(github.ref, 'refs/tags/')
146190
uses: actions/upload-artifact@v4
147191
with:
148-
name: log2src-ext-${{ env.EXT_VERSION }}.vsix.zip
149-
path: editors/code/log2src-ext-${{ env.EXT_VERSION }}.vsix
192+
name: log2src-ext-${{ github.ref_name }}.vsix
193+
path: editors/code/log2src-ext-*.vsix
150194
if-no-files-found: error
151195

152196
release:
153197
name: Create Release
154-
needs: [build-rust, vscode-extension]
198+
needs: [build-release, vscode-extension]
155199
if: startsWith(github.ref, 'refs/tags/')
156200
runs-on: ubuntu-latest
157201

0 commit comments

Comments
 (0)