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 Node
80 uses: actions/setup-node@v3
81 with:
82 node-version: "18"
83
84 - name: Checkout repo
85 uses: actions/checkout@v3
86 with:
87 clean: false
88 submodules: "recursive"
89
90 - name: Limit target directory size
91 run: script/clear-target-dir-if-larger-than 100
92
93 - name: Determine version and release channel
94 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
95 run: |
96 set -eu
97
98 version=$(script/get-crate-version zed)
99 channel=$(cat crates/zed/RELEASE_CHANNEL)
100 echo "Publishing version: ${version} on release channel ${channel}"
101 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
102
103 expected_tag_name=""
104 case ${channel} in
105 stable)
106 expected_tag_name="v${version}";;
107 preview)
108 expected_tag_name="v${version}-pre";;
109 nightly)
110 expected_tag_name="v${version}-nightly";;
111 *)
112 echo "can't publish a release on channel ${channel}"
113 exit 1;;
114 esac
115 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
116 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
117 exit 1
118 fi
119
120 - name: Generate license file
121 run: script/generate-licenses
122
123 - name: Create app bundle
124 run: script/bundle
125
126 - name: Upload app bundle to workflow run if main branch or specific label
127 uses: actions/upload-artifact@v3
128 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
129 with:
130 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
131 path: target/release/Zed.dmg
132
133 - uses: softprops/action-gh-release@v1
134 name: Upload app bundle to release
135 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
136 with:
137 draft: true
138 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
139 files: target/release/Zed.dmg
140 body: ""
141 env:
142 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}