cicd: use sccache to cache workflow compilation steps #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package VS Code Plugin | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
jobs: | |
package: | |
name: Package - ${{ matrix.platform.code_target }} | |
if: github.event.pull_request.draft == false | |
strategy: | |
matrix: | |
platform: | |
- os: windows-latest | |
rust_target: x86_64-pc-windows-msvc | |
code_target: win32-x64 | |
- os: macOS-latest | |
rust_target: x86_64-apple-darwin | |
code_target: darwin-x64 | |
- os: macOS-latest | |
rust_target: aarch64-apple-darwin | |
code_target: darwin-arm64 | |
- os: ubuntu-20.04 | |
rust_target: x86_64-unknown-linux-gnu | |
code_target: linux-x64 | |
- os: ubuntu-20.04 | |
rust_target: aarch64-unknown-linux-gnu | |
code_target: linux-arm64 | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Run sccache-cache only on non-release runs | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
uses: mozilla-actions/[email protected] | |
- name: Set Rust caching env vars only on non-release runs | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
run: | | |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV | |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- uses: extractions/setup-just@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Build harper-ls | |
uses: houseabsolute/actions-rust-cross@v0 | |
with: | |
target: ${{ matrix.platform.rust_target }} | |
args: "--locked --release --bin harper-ls" | |
strip: true | |
- name: Package extension | |
shell: bash | |
run: | | |
bin_dir="packages/vscode-plugin/bin" | |
release_dir="target/${{ matrix.platform.rust_target }}/release" | |
mkdir "$bin_dir" | |
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | |
cp "${release_dir}/harper-ls.exe" "$bin_dir" | |
else | |
cp "${release_dir}/harper-ls" "$bin_dir" | |
fi | |
just package-vscode ${{ matrix.platform.code_target }} | |
- name: Upload extension | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform.code_target }} | |
path: "packages/vscode-plugin/*.vsix" |