aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-04 16:18:37 +0000
committerAleksey Kladov <[email protected]>2020-03-04 16:18:37 +0000
commit86ec5b391732679770c8706f9d336e1f0d34bf02 (patch)
tree08ce28b3d0e6352a6bf600b968e6ccac03df6893
parent56f0f15805813b91a7a0778163d977a71adc4d00 (diff)
Nightly binary releases
This doesn't publish nightly plugin to the marketplace yet
-rw-r--r--.github/actions/github-release/Dockerfile8
-rw-r--r--.github/actions/github-release/README.md21
-rw-r--r--.github/actions/github-release/action.yml15
-rw-r--r--.github/actions/github-release/main.js117
-rw-r--r--.github/actions/github-release/package.json10
-rw-r--r--.github/workflows/release.yaml59
6 files changed, 183 insertions, 47 deletions
diff --git a/.github/actions/github-release/Dockerfile b/.github/actions/github-release/Dockerfile
new file mode 100644
index 000000000..5849eac7d
--- /dev/null
+++ b/.github/actions/github-release/Dockerfile
@@ -0,0 +1,8 @@
1FROM node:slim
2
3COPY . /action
4WORKDIR /action
5
6RUN npm install --production
7
8ENTRYPOINT ["node", "/action/main.js"]
diff --git a/.github/actions/github-release/README.md b/.github/actions/github-release/README.md
new file mode 100644
index 000000000..7b50d0020
--- /dev/null
+++ b/.github/actions/github-release/README.md
@@ -0,0 +1,21 @@
1# github-release
2
3Copy-pasted from
4https://github.com/bytecodealliance/wasmtime/tree/8acfdbdd8aa550d1b84e0ce1e6222a6605d14e38/.github/actions/github-release
5
6An action used to publish GitHub releases for `wasmtime`.
7
8As of the time of this writing there's a few actions floating around which
9perform github releases but they all tend to have their set of drawbacks.
10Additionally nothing handles deleting releases which we need for our rolling
11`dev` release.
12
13To handle all this this action rolls-its-own implementation using the
14actions/toolkit repository and packages published there. These run in a Docker
15container and take various inputs to orchestrate the release from the build.
16
17More comments can be found in `main.js`.
18
19Testing this is really hard. If you want to try though run `npm install` and
20then `node main.js`. You'll have to configure a bunch of env vars though to get
21anything reasonably working.
diff --git a/.github/actions/github-release/action.yml b/.github/actions/github-release/action.yml
new file mode 100644
index 000000000..51a074adf
--- /dev/null
+++ b/.github/actions/github-release/action.yml
@@ -0,0 +1,15 @@
1name: 'wasmtime github releases'
2description: 'wasmtime github releases'
3inputs:
4 token:
5 description: ''
6 required: true
7 name:
8 description: ''
9 required: true
10 files:
11 description: ''
12 required: true
13runs:
14 using: 'docker'
15 image: 'Dockerfile'
diff --git a/.github/actions/github-release/main.js b/.github/actions/github-release/main.js
new file mode 100644
index 000000000..295c02626
--- /dev/null
+++ b/.github/actions/github-release/main.js
@@ -0,0 +1,117 @@
1const core = require('@actions/core');
2const path = require("path");
3const fs = require("fs");
4const github = require('@actions/github');
5const glob = require('glob');
6
7function sleep(milliseconds) {
8 return new Promise(resolve => setTimeout(resolve, milliseconds))
9}
10
11async function runOnce() {
12 // Load all our inputs and env vars. Note that `getInput` reads from `INPUT_*`
13 const files = core.getInput('files');
14 const name = core.getInput('name');
15 const token = core.getInput('token');
16 const slug = process.env.GITHUB_REPOSITORY;
17 const owner = slug.split('/')[0];
18 const repo = slug.split('/')[1];
19 const sha = process.env.GITHUB_SHA;
20
21 core.info(`files: ${files}`);
22 core.info(`name: ${name}`);
23 core.info(`token: ${token}`);
24
25 const octokit = new github.GitHub(token);
26
27 // Delete the previous release since we can't overwrite one. This may happen
28 // due to retrying an upload or it may happen because we're doing the dev
29 // release.
30 const releases = await octokit.paginate("GET /repos/:owner/:repo/releases", { owner, repo });
31 for (const release of releases) {
32 if (release.tag_name !== name) {
33 continue;
34 }
35 const release_id = release.id;
36 core.info(`deleting release ${release_id}`);
37 await octokit.repos.deleteRelease({ owner, repo, release_id });
38 }
39
40 // We also need to update the `dev` tag while we're at it on the `dev` branch.
41 if (name == 'nightly') {
42 try {
43 core.info(`updating nightly tag`);
44 await octokit.git.updateRef({
45 owner,
46 repo,
47 ref: 'tags/nightly',
48 sha,
49 force: true,
50 });
51 } catch (e) {
52 console.log("ERROR: ", JSON.stringify(e, null, 2));
53 core.info(`creating nightly tag`);
54 await octokit.git.createTag({
55 owner,
56 repo,
57 tag: 'nightly',
58 message: 'nightly release',
59 object: sha,
60 type: 'commit',
61 });
62 }
63 }
64
65 // Creates an official GitHub release for this `tag`, and if this is `dev`
66 // then we know that from the previous block this should be a fresh release.
67 core.info(`creating a release`);
68 const release = await octokit.repos.createRelease({
69 owner,
70 repo,
71 tag_name: name,
72 prerelease: name === 'nightly',
73 });
74
75 // Upload all the relevant assets for this release as just general blobs.
76 for (const file of glob.sync(files)) {
77 const size = fs.statSync(file).size;
78 core.info(`upload ${file}`);
79 await octokit.repos.uploadReleaseAsset({
80 data: fs.createReadStream(file),
81 headers: { 'content-length': size, 'content-type': 'application/octet-stream' },
82 name: path.basename(file),
83 url: release.data.upload_url,
84 });
85 }
86}
87
88async function run() {
89 const retries = 10;
90 for (let i = 0; i < retries; i++) {
91 try {
92 await runOnce();
93 break;
94 } catch (e) {
95 if (i === retries - 1)
96 throw e;
97 logError(e);
98 console.log("RETRYING after 10s");
99 await sleep(10000)
100 }
101 }
102}
103
104function logError(e) {
105 console.log("ERROR: ", e.message);
106 try {
107 console.log(JSON.stringify(e, null, 2));
108 } catch (e) {
109 // ignore json errors for now
110 }
111 console.log(e.stack);
112}
113
114run().catch(err => {
115 logError(err);
116 core.setFailed(err.message);
117});
diff --git a/.github/actions/github-release/package.json b/.github/actions/github-release/package.json
new file mode 100644
index 000000000..abfc55f6f
--- /dev/null
+++ b/.github/actions/github-release/package.json
@@ -0,0 +1,10 @@
1{
2 "name": "wasmtime-github-release",
3 "version": "0.0.0",
4 "main": "main.js",
5 "dependencies": {
6 "@actions/core": "^1.0.0",
7 "@actions/github": "^1.0.0",
8 "glob": "^7.1.5"
9 }
10}
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index fe893e005..30f1ff22f 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -1,5 +1,8 @@
1name: release 1name: release
2on: 2on:
3 schedule:
4 - cron: '0 0 * * *' # midnight UTC
5
3 push: 6 push:
4 branches: 7 branches:
5 - release 8 - release
@@ -113,6 +116,9 @@ jobs:
113 node-version: 12.x 116 node-version: 12.x
114 117
115 - run: echo "::set-env name=TAG::$(date --iso)" 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'
116 - run: 'echo "TAG: $TAG"' 122 - run: 'echo "TAG: $TAG"'
117 123
118 - name: Checkout repository 124 - name: Checkout repository
@@ -136,59 +142,18 @@ jobs:
136 path: dist 142 path: dist
137 - run: ls -all ./dist 143 - run: ls -all ./dist
138 144
139 - name: Create Release 145 - name: Publish Release
140 id: create_release 146 uses: ./.github/actions/github-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/[email protected]
153 env:
154 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155 with:
156 upload_url: ${{ steps.create_release.outputs.upload_url }}
157 asset_path: ./dist/rust-analyzer-linux
158 asset_name: rust-analyzer-linux
159 asset_content_type: application/octet-stream
160
161 - uses: actions/[email protected]
162 env:
163 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164 with:
165 upload_url: ${{ steps.create_release.outputs.upload_url }}
166 asset_path: ./dist/rust-analyzer-mac
167 asset_name: rust-analyzer-mac
168 asset_content_type: application/octet-stream
169
170 - uses: actions/[email protected]
171 env:
172 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173 with:
174 upload_url: ${{ steps.create_release.outputs.upload_url }}
175 asset_path: ./dist/rust-analyzer-windows.exe
176 asset_name: rust-analyzer-windows.exe
177 asset_content_type: application/octet-stream
178
179 - uses: actions/[email protected]
180 env:
181 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182 with: 147 with:
183 upload_url: ${{ steps.create_release.outputs.upload_url }} 148 files: "dist/*"
184 asset_path: ./dist/rust-analyzer.vsix 149 name: ${{ env.TAG }}
185 asset_name: rust-analyzer.vsix 150 token: ${{ secrets.GITHUB_TOKEN }}
186 asset_content_type: application/octet-stream
187 151
188 - run: npm ci 152 - run: npm ci
189 working-directory: ./editors/code 153 working-directory: ./editors/code
190 154
191 - name: Publish Extension 155 - name: Publish Extension
156 if: github.event_name == 'push'
192 working-directory: ./editors/code 157 working-directory: ./editors/code
193 # token from https://dev.azure.com/rust-analyzer/ 158 # token from https://dev.azure.com/rust-analyzer/
194 run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }} 159 run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }}