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
14env:
15 CARGO_TERM_COLOR: always
16 CARGO_INCREMENTAL: 0
17 RUST_BACKTRACE: 1
18
19jobs:
20 rustfmt:
21 name: Check formatting
22 runs-on:
23 - self-hosted
24 - test
25 steps:
26 - name: Checkout repo
27 uses: actions/checkout@v3
28 with:
29 clean: false
30 submodules: "recursive"
31
32 - name: Run rustfmt
33 uses: ./.github/actions/check_formatting
34
35 tests:
36 name: Run tests
37 runs-on:
38 - self-hosted
39 - test
40 needs: rustfmt
41 steps:
42 - name: Checkout repo
43 uses: actions/checkout@v3
44 with:
45 clean: false
46 submodules: "recursive"
47
48 - name: Run tests
49 uses: ./.github/actions/run_tests
50
51 bundle:
52 name: Bundle app
53 runs-on:
54 - self-hosted
55 - bundle
56 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
57 needs: tests
58 env:
59 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
60 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
61 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
62 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
63 steps:
64 - name: Install Rust
65 run: |
66 rustup set profile minimal
67 rustup update stable
68 rustup target add aarch64-apple-darwin
69 rustup target add x86_64-apple-darwin
70 rustup target add wasm32-wasi
71
72 - name: Install Node
73 uses: actions/setup-node@v3
74 with:
75 node-version: "18"
76
77 - name: Checkout repo
78 uses: actions/checkout@v3
79 with:
80 clean: false
81 submodules: "recursive"
82
83 - name: Limit target directory size
84 run: script/clear-target-dir-if-larger-than 70
85
86 - name: Determine version and release channel
87 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
88 run: |
89 set -eu
90
91 version=$(script/get-crate-version zed)
92 channel=$(cat crates/zed/RELEASE_CHANNEL)
93 echo "Publishing version: ${version} on release channel ${channel}"
94 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
95
96 expected_tag_name=""
97 case ${channel} in
98 stable)
99 expected_tag_name="v${version}";;
100 preview)
101 expected_tag_name="v${version}-pre";;
102 nightly)
103 expected_tag_name="v${version}-nightly";;
104 *)
105 echo "can't publish a release on channel ${channel}"
106 exit 1;;
107 esac
108 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
109 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
110 exit 1
111 fi
112
113 - name: Generate license file
114 run: script/generate-licenses
115
116 - name: Create app bundle
117 run: script/bundle
118
119 - name: Upload app bundle to workflow run if main branch or specific label
120 uses: actions/upload-artifact@v3
121 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
122 with:
123 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
124 path: target/release/Zed.dmg
125
126 - uses: softprops/action-gh-release@v1
127 name: Upload app bundle to release
128 # TODO kb seems that zed.dev relies on GitHub releases for release version tracking.
129 # Find alternatives for `nightly` or just go on with more releases?
130 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
131 with:
132 draft: true
133 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
134 files: target/release/Zed.dmg
135 body: ""
136 env:
137 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}