]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
cargo xtask dist
[rust.git] / .github / workflows / release.yaml
1 name: release
2 on:
3   schedule:
4   - cron: '0 0 * * *' # midnight UTC
5
6   push:
7     branches:
8     - release
9
10 jobs:
11   build-server:
12     name: build-server
13     runs-on: ${{ matrix.os }}
14     strategy:
15       matrix:
16         os: [ubuntu-latest, windows-latest, macos-latest]
17
18     env:
19       RUSTFLAGS: -D warnings
20       CARGO_INCREMENTAL: 0
21       RUSTUP_MAX_RETRIES: 10
22       CARGO_NET_RETRY: 10
23
24     steps:
25     - name: Checkout repository
26       uses: actions/checkout@v1
27
28     # We need to disable the existing toolchain to avoid updating rust-docs
29     # which takes a long time. The fastest way to do this is to rename the
30     # existing folder, as deleting it takes about as much time as not doing
31     # anything and just updating rust-docs.
32     - name: Rename existing rust toolchain (Windows)
33       if: matrix.os == 'windows-latest'
34       run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
35
36     - name: Install Rust toolchain
37       uses: actions-rs/toolchain@v1
38       with:
39         toolchain: stable
40         profile: minimal
41         target: x86_64-unknown-linux-musl
42         override: true
43
44     - name: Create distribution dir
45       run: mkdir ./dist
46
47     - name: Build
48       if: matrix.os == 'ubuntu-latest'
49       run: cargo build --package rust-analyzer --bin rust-analyzer --release --target x86_64-unknown-linux-musl
50       env:
51         CC: clang
52
53     - name: Build VS Code extension
54       if: matrix.os == 'ubuntu-latest' && github.event_name == 'push'
55       run: cargo xtask dist
56
57     - name: Build VS Code extension
58       if: matrix.os == 'ubuntu-latest' && github.event_name != 'push'
59       run: cargo xtask dist --nightly
60
61     - name: Build
62       if: matrix.os != 'ubuntu-latest'
63       run: cargo build --package rust-analyzer --bin rust-analyzer --release
64
65     - name: Copy binary
66       if: matrix.os == 'ubuntu-latest'
67       run: cp ./target/x86_64-unknown-linux-musl/release/rust-analyzer ./dist/rust-analyzer-linux && strip ./dist/rust-analyzer-linux
68
69     - name: Copy binary
70       if: matrix.os == 'macos-latest'
71       run: cp ./target/release/rust-analyzer ./dist/rust-analyzer-mac
72
73     - name: Copy binary
74       if: matrix.os == 'windows-latest'
75       run: copy ./target/release/rust-analyzer.exe ./dist/rust-analyzer-windows.exe
76
77     - name: Upload artifacts
78       uses: actions/upload-artifact@v1
79       with:
80         name: server-${{ matrix.os }}
81         path: ./dist
82
83   make-release:
84     name: make-release
85     runs-on: ubuntu-latest
86     needs: ['build-server', 'build-clients']
87     steps:
88     - name: Install Nodejs
89       uses: actions/setup-node@v1
90       with:
91         node-version: 12.x
92
93     - run: echo "::set-env name=TAG::$(date --iso)"
94       if: github.event_name == 'push'
95     - run: echo "::set-env name=TAG::nightly"
96       if: github.event_name != 'push'
97     - run: 'echo "TAG: $TAG"'
98
99     - name: Checkout repository
100       uses: actions/checkout@v1
101
102     - uses: actions/download-artifact@v1
103       with:
104         name: editor-plugins
105         path: dist
106     - uses: actions/download-artifact@v1
107       with:
108         name: server-macos-latest
109         path: dist
110     - uses: actions/download-artifact@v1
111       with:
112         name: server-ubuntu-latest
113         path: dist
114     - uses: actions/download-artifact@v1
115       with:
116         name: server-windows-latest
117         path: dist
118     - run: ls -all ./dist
119
120     - name: Publish Release
121       uses: ./.github/actions/github-release
122       with:
123         files: "dist/*"
124         name: ${{ env.TAG }}
125         token: ${{ secrets.GITHUB_TOKEN }}
126
127     - run: npm ci
128       working-directory: ./editors/code
129
130     - name: Publish Extension
131       if: github.event_name == 'push'
132       working-directory: ./editors/code
133       # token from https://dev.azure.com/rust-analyzer/
134       run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix