Skip to content

Commit 7458668

Browse files
committed
Update extension release workflow
1 parent 181f1d9 commit 7458668

1 file changed

Lines changed: 45 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,60 @@ on:
99

1010
jobs:
1111
build:
12+
environment: release
13+
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"
24+
node-version: "16"
25+
2226
- run: npm version ${{ github.event.inputs.version }}
23-
- run: npm install
27+
- run: npm ci
2428
- 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 }}
30-
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 }}
29+
30+
- name: Create release and upload release asset
31+
uses: actions/github-script@v6
4032
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
33+
script: |
34+
const release = await octokit.repos.createRelease({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
tag_name: "release-v${{ github.event.inputs.version }}",
38+
name: "v${{ github.event.inputs.version }}",
39+
draft: false,
40+
prerelease: false
41+
});
42+
43+
const path = "./vscode-github-actions-${{ github.event.inputs.version }}.vsix";
44+
const vsix = fs.readFileSync(path);
45+
await octokit.repos.uploadReleaseAsset({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
release_id: release.data.id,
49+
data: fs.readFileSync(path).toString(),
50+
name: "vscode-github-actions-1.0.0.vsix",
51+
headers: {
52+
"content-type": "application/vsix",
53+
"content-length": fs.statSync(path).size
54+
}
55+
4556
- name: Publish to marketplace
46-
uses: HaaLeo/publish-vscode-extension@v0
57+
# https://github.com/HaaLeo/publish-vscode-extension/releases/tag/v1.2.0
58+
uses: HaaLeo/publish-vscode-extension@c1a0486c5a3eed24e8c21d4e37889a7c4c60c443
4759
with:
4860
pat: ${{ secrets.PUBLISHER_KEY }}
4961
registryUrl: https://marketplace.visualstudio.com
5062
extensionFile: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix
51-
packagePath: ""
52-
- run: git push
63+
64+
- name: Push version bump
65+
run: |
66+
git config --global user.email "[email protected]"
67+
git config --global user.name "GitHub Actions"
68+
git push

0 commit comments

Comments
 (0)