ci.yml

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