-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (107 loc) · 3.16 KB
/
publish.yml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Publish VSCode extension
on:
workflow_call:
secrets:
OPEN_VSX_TOKEN:
required: true
VS_MARKETPLACE_TOKEN:
required: true
workflow_dispatch:
concurrency:
group: publish
jobs:
tag-publish:
name: Tag the new version
runs-on: ubuntu-latest
needs:
- should-publish
if: needs.should-publish.outputs.is_new_version == 'yes' && github.ref == 'refs/heads/main'
permissions:
contents: write
outputs:
tag-name: ${{ steps.tag.outputs.tag-name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true
- name: Tag the version
id: tag
run: |
set -euxo pipefail
export CURRENT_VERSION="$(.github/workflows/get_current_extension_version.sh)"
export TAG_NAME="v$CURRENT_VERSION"
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
echo "tag-name=$TAG_NAME" >> $GITHUB_OUTPUT
publish:
name: Publish to Open VSX and VS Marketplace
runs-on: ubuntu-latest
needs:
- should-publish
- tag-publish
if: needs.should-publish.outputs.is_new_version == 'yes' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
make-release:
name: Create GitHub release
runs-on: ubuntu-latest
needs:
- should-publish
- tag-publish
- publish
if: needs.should-publish.outputs.is_new_version == 'yes' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true
- uses: taiki-e/create-gh-release-action@v1
name: Create GitHub release
with:
branch: main
ref: refs/tags/${{ needs.tag-publish.outputs.tag-name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
should-publish:
name: Did version change
runs-on: ubuntu-latest
outputs:
is_new_version: "${{ steps.check.outputs.is_new_version }}"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true
- id: check
run: |
set +e
.github/workflows/is_extension_version_already_tagged.sh
export EXIT_CODE="$?"
set -e
if [[ "$EXIT_CODE" == "7" ]]; then
echo 'is_new_version=no' >> $GITHUB_OUTPUT
elif [[ "$EXIT_CODE" == "0" ]]; then
echo 'is_new_version=yes' >> $GITHUB_OUTPUT
else
# Unexpected outcome, indicates a bug.
exit "$EXIT_CODE"
fi