-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (80 loc) · 3.52 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
on:
pull_request:
types:
- closed
branches:
- main
name: Build and publish a release
jobs:
is_merged_release:
name: Ensure PR was merged
if: >
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:
- run: |
echo "This is a canonical hack to run GitHub Actions on merged PRs"
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges"
- name: Comment on PR with link to this action
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
[Preparing][preparing] to publish a release.
[preparing]: ${{ github.server_url }}/${{ github.repository }}/actions/run/${{ github.run_id }}
build:
name: Build release artifact
needs: is_merged_release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get NPM metadata
id: npm_metadata
run: |
sudo apt-get install jq
echo "name=$(jq --raw-output '.name' package.json)" >> "$GITHUB_OUTPUT"
echo "displayName=$(jq --raw-output '.displayName' package.json)" >> "$GITHUB_OUTPUT"
echo "description=$(jq --raw-output '.description' package.json)" >> "$GITHUB_OUTPUT"
echo "version=$(jq --raw-output '.version' package.json)" >> "$GITHUB_OUTPUT"
- name: Build artifact
run: npm run build
- name: Tag commit
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_sha: ${{ github.event.pull_request.merge_commit_sha }}
custom_tag: ${{ steps.npm_metadata.outputs.version }}
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
prerelease: false
generate_release_notes: false
tag_name: v${{ steps.npm_metadata.outputs.version }}
body: |
# ${{ steps.npm_metadata.outputs.displayName }} v${{ steps.npm_metadata.outputs.version }}
${{ steps.npm_metadata.outputs.description }}
To install, download `${{ steps.npm_metadata.outputs.name }}-${{ steps.npm_metadata.outputs.version }}.vsix`, open a terminal to the download directory, and run
```
code --install-extension ${{ steps.npm_metadata.outputs.name }}-${{ steps.npm_metadata.outputs.version }}.vsix
```
files: |
${{ steps.npm_metadata.outputs.name }}-${{ steps.npm_metadata.outputs.version }}.vsix
- name: Comment on PR with link to the release
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
[Release ${{ steps.npm_metadata.outputs.version }}][release] was built and published successfully!
[release]: ${{ steps.create_release.outputs.url }}
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.npm_metadata.outputs.name }}-${{ steps.npm_metadata.outputs.version }}.vsix