1name: CI
2
3on:
4 push:
5 branches:
6 - main
7 - "v[0-9]+.[0-9]+.x"
8 tags:
9 - "v*"
10 pull_request:
11 branches:
12 - "**"
13
14env:
15 CARGO_TERM_COLOR: always
16 CARGO_INCREMENTAL: 0
17 RUST_BACKTRACE: 1
18
19jobs:
20 rustfmt:
21 name: Check formatting
22 runs-on:
23 - self-hosted
24 - test
25 steps:
26 - name: Install Rust
27 run: |
28 rustup set profile minimal
29 rustup update stable
30
31 - name: Checkout repo
32 uses: actions/checkout@v3
33 with:
34 clean: false
35 submodules: "recursive"
36
37 - name: cargo fmt
38 run: cargo fmt --all -- --check
39
40 tests:
41 name: Run tests
42 runs-on:
43 - self-hosted
44 - test
45 needs: rustfmt
46 env:
47 RUSTFLAGS: -D warnings
48 steps:
49 - name: Install Rust
50 run: |
51 rustup set profile minimal
52 rustup update stable
53 rustup target add wasm32-wasi
54 cargo install cargo-nextest
55
56 - name: Install Node
57 uses: actions/setup-node@v3
58 with:
59 node-version: "18"
60
61 - name: Checkout repo
62 uses: actions/checkout@v3
63 with:
64 clean: false
65 submodules: "recursive"
66
67 - name: Limit target directory size
68 run: script/clear-target-dir-if-larger-than 70
69
70 - name: Run check
71 run: cargo check --workspace
72
73 - name: Run tests
74 run: cargo nextest run --workspace --no-fail-fast
75
76 - name: Build collab
77 run: cargo build -p collab
78
79 - name: Build other binaries
80 run: cargo build --workspace --bins --all-features
81
82 bundle:
83 name: Bundle app
84 runs-on:
85 - self-hosted
86 - bundle
87 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
88 needs: tests
89 env:
90 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
91 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
92 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
93 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
94 steps:
95 - name: Install Rust
96 run: |
97 rustup set profile minimal
98 rustup update stable
99 rustup target add aarch64-apple-darwin
100 rustup target add x86_64-apple-darwin
101 rustup target add wasm32-wasi
102
103 - name: Install Node
104 uses: actions/setup-node@v3
105 with:
106 node-version: "18"
107
108 - name: Checkout repo
109 uses: actions/checkout@v3
110 with:
111 clean: false
112 submodules: "recursive"
113
114 - name: Limit target directory size
115 run: script/clear-target-dir-if-larger-than 70
116
117 - name: Determine version and release channel
118 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
119 run: |
120 set -eu
121
122 version=$(script/get-crate-version zed)
123 channel=$(cat crates/zed/RELEASE_CHANNEL)
124 echo "Publishing version: ${version} on release channel ${channel}"
125 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
126
127 expected_tag_name=""
128 case ${channel} in
129 stable)
130 expected_tag_name="v${version}";;
131 preview)
132 expected_tag_name="v${version}-pre";;
133 nightly)
134 expected_tag_name="v${version}-nightly";;
135 *)
136 echo "can't publish a release on channel ${channel}"
137 exit 1;;
138 esac
139 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
140 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
141 exit 1
142 fi
143
144 - name: Generate license file
145 run: script/generate-licenses
146
147 - name: Create app bundle
148 run: script/bundle
149
150 - name: Upload app bundle to workflow run if main branch or specific label
151 uses: actions/upload-artifact@v3
152 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
153 with:
154 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
155 path: target/release/Zed.dmg
156
157 - uses: softprops/action-gh-release@v1
158 name: Upload app bundle to release
159 # TODO kb seems that zed.dev relies on GitHub releases for release version tracking.
160 # Find alternatives for `nightly` or just go on with more releases?
161 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
162 with:
163 draft: true
164 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
165 files: target/release/Zed.dmg
166 body: ""
167 env:
168 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}