zed/.github/workflows/ci.yml

168 lines
4.5 KiB
YAML
Raw Normal View History

2021-04-03 00:43:30 +03:00
name: CI
on:
push:
branches:
- main
- "v[0-9]+.[0-9]+.x"
2021-05-18 01:47:42 +03:00
tags:
- "v*"
2021-04-03 00:43:30 +03:00
pull_request:
branches:
- "**"
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
2021-05-19 15:24:23 +03:00
RUST_BACKTRACE: 1
2021-04-03 00:43:30 +03:00
jobs:
rustfmt:
name: Check formatting
runs-on:
- self-hosted
- test
steps:
- name: Install Rust
run: |
rustup set profile minimal
rustup update stable
- name: Checkout repo
2023-07-12 22:17:13 +03:00
uses: actions/checkout@v3
with:
clean: false
submodules: 'recursive'
- name: cargo fmt
run: cargo fmt --all -- --check
2021-05-18 06:57:07 +03:00
tests:
name: Run tests
runs-on:
2022-03-02 16:41:40 +03:00
- self-hosted
- test
needs: rustfmt
env:
RUSTFLAGS: -D warnings
2021-05-18 06:57:07 +03:00
steps:
- name: Install Rust
run: |
rustup set profile minimal
rustup update stable
rustup target add wasm32-wasi
cargo install cargo-nextest
2022-07-11 19:29:27 +03:00
- name: Install Node
2023-07-12 22:17:13 +03:00
uses: actions/setup-node@v3
with:
2023-04-18 02:22:30 +03:00
node-version: '18'
2021-05-18 06:57:07 +03:00
- name: Checkout repo
2023-07-12 22:17:13 +03:00
uses: actions/checkout@v3
2021-05-18 07:46:33 +03:00
with:
clean: false
2022-10-24 15:28:58 +03:00
submodules: 'recursive'
- name: Limit target directory size
run: script/clear-target-dir-if-larger-than 70
- name: Run check
run: cargo check --workspace
2021-05-18 06:57:07 +03:00
- name: Run tests
run: cargo nextest run --workspace --no-fail-fast
- name: Build collab
run: cargo build -p collab
- name: Build other binaries
run: cargo build --workspace --bins --all-features
- name: Generate license file
run: script/generate-licenses
2021-05-18 01:18:31 +03:00
bundle:
name: Bundle app
runs-on:
2022-03-02 16:41:40 +03:00
- self-hosted
- bundle
2023-05-18 13:49:55 +03:00
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
needs: tests
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
2021-09-11 08:11:22 +03:00
APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
2021-05-18 01:18:31 +03:00
steps:
- name: Install Rust
run: |
rustup set profile minimal
rustup update stable
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
rustup target add wasm32-wasi
2021-05-18 03:07:39 +03:00
- name: Install Node
2023-07-12 22:17:13 +03:00
uses: actions/setup-node@v3
with:
2023-04-18 02:22:30 +03:00
node-version: '18'
- name: Checkout repo
2023-07-12 22:17:13 +03:00
uses: actions/checkout@v3
2021-05-18 07:46:33 +03:00
with:
clean: false
2022-10-24 15:28:58 +03:00
submodules: 'recursive'
- name: Limit target directory size
run: script/clear-target-dir-if-larger-than 70
- name: Determine version and release channel
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
2022-10-26 00:24:20 +03:00
run: |
set -eu
version=$(script/get-crate-version zed)
channel=$(cat crates/zed/RELEASE_CHANNEL)
echo "Publishing version: ${version} on release channel ${channel}"
echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
expected_tag_name=""
case ${channel} in
stable)
expected_tag_name="v${version}";;
preview)
expected_tag_name="v${version}-pre";;
*)
echo "can't publish a release on channel ${channel}"
exit 1;;
esac
2022-10-27 03:21:31 +03:00
if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
2022-10-26 00:24:20 +03:00
exit 1
fi
- name: Generate license file
run: script/generate-licenses
2021-05-18 01:18:31 +03:00
- name: Create app bundle
run: script/bundle
2021-05-18 01:18:31 +03:00
2023-07-13 11:52:35 +03:00
- name: Upload app bundle to workflow run if main branch or specific label
uses: actions/upload-artifact@v3
2023-05-18 13:49:55 +03:00
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
with:
2023-05-18 13:49:55 +03:00
name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
path: target/release/Zed.dmg
2021-05-18 01:18:31 +03:00
2021-05-18 08:39:01 +03:00
- uses: softprops/action-gh-release@v1
name: Upload app bundle to release
if: ${{ env.RELEASE_CHANNEL }}
2021-05-18 01:18:31 +03:00
with:
2021-05-18 08:39:01 +03:00
draft: true
prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
2021-05-18 08:39:01 +03:00
files: target/release/Zed.dmg
2021-05-18 01:18:31 +03:00
body: ""
2021-05-18 08:39:01 +03:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}