Skip to content

Commit 1dbe039

Browse files
authored
Merge pull request #116 from github/joshmgross/release-workflow
Update extension release workflow
2 parents 5bcee03 + dd328ba commit 1dbe039

1 file changed

Lines changed: 71 additions & 31 deletions

File tree

.github/workflows/release.yml

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
name: Release new version
1+
name: Release and publish extension
2+
3+
run-name: Release v${{ github.event.inputs.version }}
24

35
on:
46
workflow_dispatch:
@@ -8,45 +10,83 @@ on:
810
description: "Version to bump `package.json` to (format: x.y.z)"
911

1012
jobs:
11-
build:
13+
release:
1214
runs-on: ubuntu-latest
1315

16+
permissions:
17+
contents: write
18+
1419
steps:
15-
- uses: actions/checkout@v2
16-
- run: |
17-
git config --global user.email "[email protected]"
18-
git config --global user.name "Christopher Schleiden"
19-
- uses: actions/setup-node@v2
20+
- uses: actions/checkout@v3
21+
22+
- uses: actions/setup-node@v3
2023
with:
21-
node-version: "12"
22-
- run: npm version ${{ github.event.inputs.version }}
23-
- run: npm install
24+
node-version: "16"
25+
26+
- name: Bump version and push
27+
run: |
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "GitHub Actions"
30+
31+
npm version ${{ github.event.inputs.version }} --no-git-tag-version
32+
git add package.json package-lock.json
33+
git commit -m "Release extension version ${{ github.event.inputs.version }}"
34+
35+
git push
36+
37+
- run: npm ci
2438
- run: npm run package
25-
- name: Create Release
26-
id: create_release
27-
uses: actions/create-release@v1
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- uses: actions/upload-artifact@v3
3041
with:
31-
tag_name: "release-v${{ github.event.inputs.version }}"
32-
release_name: "v${{ github.event.inputs.version }}"
33-
draft: false
34-
prerelease: false
35-
- name: Upload Release Asset
36-
id: upload-release-asset
37-
uses: actions/upload-release-asset@v1
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
name: vscode-github-actions-${{ github.event.inputs.version }}.vsix
43+
path: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix
44+
45+
- name: Create release and upload release asset
46+
uses: actions/github-script@v6
4047
with:
41-
upload_url: ${{ steps.create_release.outputs.upload_url }}
42-
asset_path: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix
43-
asset_name: vscode-github-actions-${{ github.event.inputs.version }}.vsix
44-
asset_content_type: application/vsix
48+
script: |
49+
const fs = require("fs");
50+
51+
const release = await github.rest.repos.createRelease({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
tag_name: "release-v${{ github.event.inputs.version }}",
55+
name: "v${{ github.event.inputs.version }}",
56+
draft: false,
57+
prerelease: false
58+
});
59+
60+
const path = "./vscode-github-actions-${{ github.event.inputs.version }}.vsix";
61+
await github.rest.repos.uploadReleaseAsset({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
release_id: release.data.id,
65+
data: fs.readFileSync(path).toString(),
66+
name: "vscode-github-actions-${{ github.event.inputs.version }}.vsix",
67+
headers: {
68+
"content-type": "application/vsix",
69+
"content-length": fs.statSync(path).size
70+
}
71+
});
72+
73+
publish:
74+
environment: publish
75+
76+
needs: release
77+
78+
runs-on: ubuntu-latest
79+
permissions: {}
80+
81+
steps:
82+
- uses: actions/download-artifact@v3
83+
with:
84+
name: vscode-github-actions-${{ github.event.inputs.version }}.vsix
85+
4586
- name: Publish to marketplace
46-
uses: HaaLeo/publish-vscode-extension@v0
87+
# https://github.com/HaaLeo/publish-vscode-extension/releases/tag/v1.2.0
88+
uses: HaaLeo/publish-vscode-extension@c1a0486c5a3eed24e8c21d4e37889a7c4c60c443
4789
with:
4890
pat: ${{ secrets.PUBLISHER_KEY }}
4991
registryUrl: https://marketplace.visualstudio.com
5092
extensionFile: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix
51-
packagePath: ""
52-
- run: git push

0 commit comments

Comments
 (0)