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