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 - name: Generate license file
83 run: script/generate-licenses
84
85 bundle:
86 name: Bundle app
87 runs-on:
88 - self-hosted
89 - bundle
90 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
91 needs: tests
92 env:
93 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
94 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
95 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
96 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
97 steps:
98 - name: Install Rust
99 run: |
100 rustup set profile minimal
101 rustup update stable
102 rustup target add aarch64-apple-darwin
103 rustup target add x86_64-apple-darwin
104 rustup target add wasm32-wasi
105
106 - name: Install Node
107 uses: actions/setup-node@v3
108 with:
109 node-version: '18'
110
111 - name: Checkout repo
112 uses: actions/checkout@v3
113 with:
114 clean: false
115 submodules: 'recursive'
116
117 - name: Limit target directory size
118 run: script/clear-target-dir-if-larger-than 70
119
120 - name: Determine version and release channel
121 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
122 run: |
123 set -eu
124
125 version=$(script/get-crate-version zed)
126 channel=$(cat crates/zed/RELEASE_CHANNEL)
127 echo "Publishing version: ${version} on release channel ${channel}"
128 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
129
130 expected_tag_name=""
131 case ${channel} in
132 stable)
133 expected_tag_name="v${version}";;
134 preview)
135 expected_tag_name="v${version}-pre";;
136 *)
137 echo "can't publish a release on channel ${channel}"
138 exit 1;;
139 esac
140 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
141 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
142 exit 1
143 fi
144
145 - name: Generate license file
146 run: script/generate-licenses
147
148 - name: Create app bundle
149 run: script/bundle
150
151 - name: Upload app bundle to workflow run if main branch or specific label
152 uses: actions/upload-artifact@v3
153 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
154 with:
155 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
156 path: target/release/Zed.dmg
157
158 - uses: softprops/action-gh-release@v1
159 name: Upload app bundle to release
160 if: ${{ env.RELEASE_CHANNEL }}
161 with:
162 draft: true
163 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
164 files: target/release/Zed.dmg
165 body: ""
166 env:
167 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}