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@v3
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 tests:
52 name: Run tests
53 runs-on:
54 - self-hosted
55 - test
56 steps:
57 - name: Checkout repo
58 uses: actions/checkout@v3
59 with:
60 clean: false
61 submodules: "recursive"
62
63 - name: Run tests
64 uses: ./.github/actions/run_tests
65
66 - name: Build collab
67 run: cargo build -p collab
68
69 - name: Build other binaries
70 run: cargo build --workspace --bins --all-features
71
72 bundle:
73 name: Bundle app
74 runs-on:
75 - self-hosted
76 - bundle
77 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
78 needs: tests
79 env:
80 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
81 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
82 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
83 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
84 steps:
85 - name: Install Node
86 uses: actions/setup-node@v3
87 with:
88 node-version: "18"
89
90 - name: Checkout repo
91 uses: actions/checkout@v3
92 with:
93 clean: false
94 submodules: "recursive"
95
96 - name: Limit target directory size
97 run: script/clear-target-dir-if-larger-than 100
98
99 - name: Determine version and release channel
100 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
101 run: |
102 set -eu
103
104 version=$(script/get-crate-version zed)
105 channel=$(cat crates/zed/RELEASE_CHANNEL)
106 echo "Publishing version: ${version} on release channel ${channel}"
107 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
108
109 expected_tag_name=""
110 case ${channel} in
111 stable)
112 expected_tag_name="v${version}";;
113 preview)
114 expected_tag_name="v${version}-pre";;
115 nightly)
116 expected_tag_name="v${version}-nightly";;
117 *)
118 echo "can't publish a release on channel ${channel}"
119 exit 1;;
120 esac
121 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
122 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
123 exit 1
124 fi
125
126 - name: Generate license file
127 run: script/generate-licenses
128
129 - name: Create app bundle
130 run: script/bundle
131
132 - name: Upload app bundle to workflow run if main branch or specific label
133 uses: actions/upload-artifact@v3
134 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
135 with:
136 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
137 path: target/release/Zed.dmg
138
139 - uses: softprops/action-gh-release@v1
140 name: Upload app bundle to release
141 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
142 with:
143 draft: true
144 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
145 files: target/release/Zed.dmg
146 body: ""
147 env:
148 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}