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 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
55 - name: Install Node
56 uses: actions/setup-node@v2
57 with:
58 node-version: '18'
59
60 - name: Checkout repo
61 uses: actions/checkout@v2
62 with:
63 clean: false
64 submodules: 'recursive'
65
66 - name: Limit target directory size
67 run: script/clear-target-dir-if-larger-than 70
68
69 - name: Run check
70 run: cargo check --workspace
71
72 - name: Run tests
73 run: cargo test --workspace --no-fail-fast
74
75 - name: Build collab
76 run: cargo build -p collab
77
78 - name: Build other binaries
79 run: cargo build --workspace --bins --all-features
80
81 - name: Generate license file
82 run: script/generate-licenses
83
84 bundle:
85 name: Bundle app
86 runs-on:
87 - self-hosted
88 - bundle
89 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
90 needs: tests
91 env:
92 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
93 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
94 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
95 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
96 ZED_MIXPANEL_TOKEN: ${{ secrets.ZED_MIXPANEL_TOKEN }}
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@v2
108 with:
109 node-version: '18'
110
111 - name: Checkout repo
112 uses: actions/checkout@v2
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 specifi label
152 uses: actions/upload-artifact@v2
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 }}