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