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