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
14concurrency:
15 # Allow only one workflow per any non-`main` branch.
16 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
17 cancel-in-progress: true
18
19env:
20 CARGO_TERM_COLOR: always
21 CARGO_INCREMENTAL: 0
22 RUST_BACKTRACE: 1
23
24jobs:
25 style:
26 name: Check formatting, Clippy lints, and spelling
27 runs-on:
28 - self-hosted
29 - test
30 steps:
31 - name: Checkout repo
32 uses: actions/checkout@v4
33 with:
34 clean: false
35 submodules: "recursive"
36 fetch-depth: 0
37
38 - name: Set up default .cargo/config.toml
39 run: cp ./.cargo/ci-config.toml ~/.cargo/config.toml
40
41 - name: Check spelling
42 run: |
43 if ! which typos > /dev/null; then
44 cargo install typos-cli
45 fi
46 typos
47
48 - name: Run style checks
49 uses: ./.github/actions/check_style
50
51 - name: Ensure fresh merge
52 run: |
53 git checkout -B temp
54 git merge -q origin/main -m "merge main into temp"
55
56 - uses: bufbuild/buf-setup-action@v1
57 - uses: bufbuild/buf-breaking-action@v1
58 with:
59 input: "crates/rpc/proto/"
60 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main,subdir=crates/rpc/proto/"
61
62 tests:
63 name: Run tests
64 runs-on:
65 - self-hosted
66 - test
67 steps:
68 - name: Checkout repo
69 uses: actions/checkout@v4
70 with:
71 clean: false
72 submodules: "recursive"
73
74 - name: Run tests
75 uses: ./.github/actions/run_tests
76
77 - name: Build collab
78 run: cargo build -p collab
79
80 - name: Build other binaries
81 run: cargo build --workspace --bins --all-features
82
83 bundle:
84 name: Bundle app
85 runs-on:
86 - self-hosted
87 - bundle
88 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
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_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
96 steps:
97 - name: Install Node
98 uses: actions/setup-node@v4
99 with:
100 node-version: "18"
101
102 - name: Checkout repo
103 uses: actions/checkout@v4
104 with:
105 clean: false
106 submodules: "recursive"
107
108 - name: Limit target directory size
109 run: script/clear-target-dir-if-larger-than 100
110
111 - name: Determine version and release channel
112 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
113 run: |
114 set -eu
115
116 version=$(script/get-crate-version zed)
117 channel=$(cat crates/zed/RELEASE_CHANNEL)
118 echo "Publishing version: ${version} on release channel ${channel}"
119 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
120
121 expected_tag_name=""
122 case ${channel} in
123 stable)
124 expected_tag_name="v${version}";;
125 preview)
126 expected_tag_name="v${version}-pre";;
127 nightly)
128 expected_tag_name="v${version}-nightly";;
129 *)
130 echo "can't publish a release on channel ${channel}"
131 exit 1;;
132 esac
133 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
134 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
135 exit 1
136 fi
137
138 - name: Generate license file
139 run: script/generate-licenses
140
141 - name: Create app bundle
142 run: script/bundle
143
144 - name: Upload app bundle to workflow run if main branch or specific label
145 uses: actions/upload-artifact@v3
146 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
147 with:
148 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
149 path: target/release/Zed.dmg
150
151 - uses: softprops/action-gh-release@v1
152 name: Upload app bundle to release
153 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
154 with:
155 draft: true
156 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
157 files: target/release/Zed.dmg
158 body: ""
159 env:
160 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}