|
12 | 12 | CARGO_TERM_COLOR: always |
13 | 13 |
|
14 | 14 | jobs: |
15 | | - build-rust: |
16 | | - |
| 15 | + build-and-test: |
| 16 | + name: Build & Test |
17 | 17 | runs-on: ${{ matrix.os }} |
18 | 18 | timeout-minutes: 30 |
19 | 19 | strategy: |
|
56 | 56 | run: cargo build --verbose |
57 | 57 | - name: Run tests |
58 | 58 | 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 | + |
59 | 102 | - name: Build release binary |
60 | 103 | run: cargo build --release --target ${{ matrix.target }} |
61 | 104 |
|
|
82 | 125 |
|
83 | 126 | vscode-extension: |
84 | 127 | 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/') |
86 | 130 | runs-on: ubuntu-latest |
87 | 131 |
|
88 | 132 | steps: |
@@ -135,23 +179,23 @@ jobs: |
135 | 179 | working-directory: editors/code |
136 | 180 | run: | |
137 | 181 | REF_NAME="${{ github.ref_name }}" |
138 | | - echo "EXT_VERSION=${REF_NAME#v}" >> $GITHUB_ENV |
| 182 | + VERSION=${REF_NAME#v} |
139 | 183 | # 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 |
141 | 185 | mv package.json.new package.json |
142 | 186 | pnpm vsce package --no-dependencies |
143 | 187 | |
144 | 188 | - name: Upload VS Code extension |
145 | 189 | if: startsWith(github.ref, 'refs/tags/') |
146 | 190 | uses: actions/upload-artifact@v4 |
147 | 191 | 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 |
150 | 194 | if-no-files-found: error |
151 | 195 |
|
152 | 196 | release: |
153 | 197 | name: Create Release |
154 | | - needs: [build-rust, vscode-extension] |
| 198 | + needs: [build-release, vscode-extension] |
155 | 199 | if: startsWith(github.ref, 'refs/tags/') |
156 | 200 | runs-on: ubuntu-latest |
157 | 201 |
|
|
0 commit comments