]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Fix release process once more
[rust.git] / .github / workflows / release.yaml
1 name: release
2 on:
3   push:
4     branches:
5       - release
6
7 jobs:
8   build-server:
9     name: build-server
10     runs-on: ${{ matrix.os }}
11     strategy:
12       matrix:
13         os: [ubuntu-latest, windows-latest, macos-latest]
14     env:
15       RUSTFLAGS: -D warnings
16       CARGO_INCREMENTAL: 0
17       RUSTUP_MAX_RETRIES: 10
18       CARGO_NET_RETRY: 10
19     steps:
20
21       - name: Checkout repository
22         uses: actions/checkout@v1
23
24       # We need to disable the existing toolchain to avoid updating rust-docs
25       # which takes a long time. The fastest way to do this is to rename the
26       # existing folder, as deleting it takes about as much time as not doing
27       # anything and just updating rust-docs.
28       - name: Rename existing rust toolchain (Windows)
29         if: matrix.os == 'windows-latest'
30         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
31
32       - name: Install Rust toolchain
33         uses: actions-rs/toolchain@v1
34         with:
35           toolchain: stable
36           profile: minimal
37           target: x86_64-unknown-linux-musl
38           override: true
39
40       - name: Build
41         if: matrix.os == 'ubuntu-latest'
42         uses: actions-rs/cargo@v1
43         env:
44           CC: clang
45         with:
46           command: build
47           args: --package ra_lsp_server --bin ra_lsp_server --release --target x86_64-unknown-linux-musl
48
49       - name: Build
50         if: matrix.os != 'ubuntu-latest'
51         uses: actions-rs/cargo@v1
52         with:
53           command: build
54           args: --package ra_lsp_server --bin ra_lsp_server --release
55
56       - name: Create distribution dir
57         run: mkdir ./dist
58
59       - name: Copy binary
60         if: matrix.os == 'ubuntu-latest'
61         run: cp ./target/x86_64-unknown-linux-musl/release/ra_lsp_server ./dist/ra_lsp_server-linux && strip ./dist/ra_lsp_server-linux
62
63       - name: Copy binary
64         if: matrix.os == 'macos-latest'
65         run: cp ./target/release/ra_lsp_server ./dist/ra_lsp_server-mac
66
67       - name: Copy binary
68         if: matrix.os == 'windows-latest'
69         run: copy ./target/release/ra_lsp_server.exe ./dist/ra_lsp_server-windows.exe
70
71       - name: Upload artifacts
72         uses: actions/upload-artifact@v1
73         with:
74           name: server-${{ matrix.os }}
75           path: ./dist
76
77   build-clients:
78     name: build-clients
79     runs-on: ubuntu-latest
80     steps:
81       - name: Checkout repository
82         uses: actions/checkout@v1
83
84       - name: Install Nodejs
85         uses: actions/setup-node@v1
86         with:
87           node-version: 12.x
88
89       - run: npm ci
90         working-directory: ./editors/code
91
92       - run: npm run package --scripts-prepend-node-path
93         working-directory: ./editors/code
94
95       - name: Copy vscode extension
96         run: mkdir -p ./dist/code && cp ./editors/code/*.vsix ./dist/
97
98       - name: Upload artifacts
99         uses: actions/upload-artifact@v1
100         with:
101           name: editor-plugins
102           path: ./dist
103
104   make-release:
105     name: make-release
106     runs-on: ubuntu-latest
107     needs: ['build-server', 'build-clients']
108     steps:
109       - name: Install Nodejs
110         uses: actions/setup-node@v1
111         with:
112           node-version: 12.x
113
114       - run: echo "::set-env name=TAG::$(date --iso)"
115       - run: echo "::set-env name=EXT_VERSION::0.1.$(date +%Y%m%d)"
116       - run: 'echo "TAG: $TAG EXT_VERSION: $EXT_VERSION"'
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: Create Release
140         id: create_release
141         # uses: actions/create-release@v1
142         # https://github.com/actions/create-release/pull/32
143         uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
144         env:
145           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146         with:
147           tag_name: ${{ env.TAG }}
148           release_name: ${{ env.TAG }}
149           draft: false
150           prerelease: false
151
152       - uses: actions/upload-release-asset@v1.0.1
153         env:
154           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155         with:
156           upload_url: ${{ steps.create_release.outputs.upload_url }}
157           asset_path: ./dist/ra_lsp_server-linux
158           asset_name: ra_lsp_server-linux
159           asset_content_type: application/octet-stream
160
161       - uses: actions/upload-release-asset@v1.0.1
162         env:
163           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164         with:
165           upload_url: ${{ steps.create_release.outputs.upload_url }}
166           asset_path: ./dist/ra_lsp_server-mac
167           asset_name: ra_lsp_server-mac
168           asset_content_type: application/octet-stream
169
170       - uses: actions/upload-release-asset@v1.0.1
171         env:
172           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173         with:
174           upload_url: ${{ steps.create_release.outputs.upload_url }}
175           asset_path: ./dist/ra_lsp_server-windows.exe
176           asset_name: ra_lsp_server-windows.exe
177           asset_content_type: application/octet-stream
178
179       - uses: actions/upload-release-asset@v1.0.1
180         env:
181           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182         with:
183           upload_url: ${{ steps.create_release.outputs.upload_url }}
184           asset_path: ./dist/rust-analyzer-${{ env.EXT_VERSION }}.vsix
185           asset_name: rust-analyzer-${{ env.EXT_VERSION }}.vsix
186           asset_content_type: application/octet-stream
187
188       - run: npm ci
189         working-directory: ./editors/code
190
191       - name: Publish Extension
192         working-directory: ./editors/code
193         # token from https://dev.azure.com/rust-analyzer/
194         run: npx vsce publish $EXT_VERSION --pat ${{ secrets.MARKETPLACE_TOKEN }}