]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Merge pull request #3457 from matklad/simple-ci
[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: Build
45       if: matrix.os == 'ubuntu-latest'
46       run: cargo build --package rust-analyzer --bin rust-analyzer --release --target x86_64-unknown-linux-musl
47       env:
48         CC: clang
49
50     - name: Build
51       if: matrix.os != 'ubuntu-latest'
52       run: cargo build --package rust-analyzer --bin rust-analyzer --release
53
54     - name: Create distribution dir
55       run: mkdir ./dist
56
57     - name: Copy binary
58       if: matrix.os == 'ubuntu-latest'
59       run: cp ./target/x86_64-unknown-linux-musl/release/rust-analyzer ./dist/rust-analyzer-linux && strip ./dist/rust-analyzer-linux
60
61     - name: Copy binary
62       if: matrix.os == 'macos-latest'
63       run: cp ./target/release/rust-analyzer ./dist/rust-analyzer-mac
64
65     - name: Copy binary
66       if: matrix.os == 'windows-latest'
67       run: copy ./target/release/rust-analyzer.exe ./dist/rust-analyzer-windows.exe
68
69     - name: Upload artifacts
70       uses: actions/upload-artifact@v1
71       with:
72         name: server-${{ matrix.os }}
73         path: ./dist
74
75   build-clients:
76     name: build-clients
77     runs-on: ubuntu-latest
78     steps:
79     - name: Checkout repository
80       uses: actions/checkout@v1
81
82     - name: Install Nodejs
83       uses: actions/setup-node@v1
84       with:
85         node-version: 12.x
86
87     - run: npm ci
88       working-directory: ./editors/code
89
90     - run: npm run package --scripts-prepend-node-path
91       working-directory: ./editors/code
92
93     - name: Copy vscode extension
94       run: mkdir -p ./dist/code && cp ./editors/code/rust-analyzer.vsix ./dist/
95
96     - name: Upload artifacts
97       uses: actions/upload-artifact@v1
98       with:
99         name: editor-plugins
100         path: ./dist
101
102   make-release:
103     name: make-release
104     runs-on: ubuntu-latest
105     needs: ['build-server', 'build-clients']
106     steps:
107     - name: Install Nodejs
108       uses: actions/setup-node@v1
109       with:
110         node-version: 12.x
111
112     - run: echo "::set-env name=TAG::$(date --iso)"
113       if: github.event_name == 'push'
114     - run: echo "::set-env name=TAG::nightly"
115       if: github.event_name != 'push'
116     - run: 'echo "TAG: $TAG"'
117
118     - name: Checkout repository
119       uses: actions/checkout@v1
120
121     - uses: actions/download-artifact@v1
122       with:
123         name: editor-plugins
124         path: dist
125     - uses: actions/download-artifact@v1
126       with:
127         name: server-macos-latest
128         path: dist
129     - uses: actions/download-artifact@v1
130       with:
131         name: server-ubuntu-latest
132         path: dist
133     - uses: actions/download-artifact@v1
134       with:
135         name: server-windows-latest
136         path: dist
137     - run: ls -all ./dist
138
139     - name: Publish Release
140       uses: ./.github/actions/github-release
141       with:
142         files: "dist/*"
143         name: ${{ env.TAG }}
144         token: ${{ secrets.GITHUB_TOKEN }}
145
146     - run: npm ci
147       working-directory: ./editors/code
148
149     - name: Publish Extension
150       if: github.event_name == 'push'
151       working-directory: ./editors/code
152       # token from https://dev.azure.com/rust-analyzer/
153       run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }}