ci.yml

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