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