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@v2
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 env:
46 RUSTFLAGS: -D warnings
47 steps:
48 - name: Install Rust
49 run: |
50 rustup set profile minimal
51 rustup update stable
52 rustup target add wasm32-wasi
53
54 - name: Install Node
55 uses: actions/setup-node@v2
56 with:
57 node-version: '18'
58
59 - name: Checkout repo
60 uses: actions/checkout@v2
61 with:
62 clean: false
63 submodules: 'recursive'
64
65 - name: Limit target directory size
66 run: script/clear-target-dir-if-larger-than 70
67
68 - name: Run check
69 run: cargo check --workspace
70
71 - name: Run tests
72 run: cargo test --workspace --no-fail-fast
73
74 - name: Build collab
75 run: cargo build -p collab
76
77 - name: Build other binaries
78 run: cargo build --workspace --bins --all-features
79
80 - name: Generate license file
81 run: script/generate-licenses
82
83 bundle:
84 name: Bundle app
85 runs-on:
86 - self-hosted
87 - bundle
88 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
89 needs: tests
90 env:
91 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
92 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
93 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
94 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
95 ZED_MIXPANEL_TOKEN: ${{ secrets.ZED_MIXPANEL_TOKEN }}
96 steps:
97 - name: Install Rust
98 run: |
99 rustup set profile minimal
100 rustup update stable
101 rustup target add aarch64-apple-darwin
102 rustup target add x86_64-apple-darwin
103 rustup target add wasm32-wasi
104
105 - name: Install Node
106 uses: actions/setup-node@v2
107 with:
108 node-version: '18'
109
110 - name: Checkout repo
111 uses: actions/checkout@v2
112 with:
113 clean: false
114 submodules: 'recursive'
115
116 - name: Limit target directory size
117 run: script/clear-target-dir-if-larger-than 70
118
119 - name: Determine version and release channel
120 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
121 run: |
122 set -eu
123
124 version=$(script/get-crate-version zed)
125 channel=$(cat crates/zed/RELEASE_CHANNEL)
126 echo "Publishing version: ${version} on release channel ${channel}"
127 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
128
129 expected_tag_name=""
130 case ${channel} in
131 stable)
132 expected_tag_name="v${version}";;
133 preview)
134 expected_tag_name="v${version}-pre";;
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
151 uses: actions/upload-artifact@v2
152 if: ${{ github.ref == 'refs/heads/main' }}
153 with:
154 name: Zed.dmg
155 path: target/release/Zed.dmg
156
157 - uses: softprops/action-gh-release@v1
158 name: Upload app bundle to release
159 if: ${{ env.RELEASE_CHANNEL }}
160 with:
161 draft: true
162 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
163 files: target/release/Zed.dmg
164 body: ""
165 env:
166 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}