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