-
-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (163 loc) · 6.24 KB
/
release.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# MIT License
#
# Copyright (c) 2025 Mickaël CANOUIL
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: Release and Publish VS Code Extension
on:
workflow_dispatch:
inputs:
type:
type: choice
description: Type
options:
- release
- pre-release
default: pre-release
date:
type: string
description: 'Date ("YYYY-MM-DD" or "today")'
default: today
jobs:
update-changelog:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
BRANCH: ci/update-changelog-release
GITHUB_TOKEN: ${{ secrets.github_token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for "unreleased" in CHANGELOG.md
id: check_unreleased
shell: bash
run: |
if grep -q "unreleased" CHANGELOG.md; then
echo "UNRELEASED_FOUND=true" >> $GITHUB_OUTPUT
else
echo "UNRELEASED_FOUND=false" >> $GITHUB_OUTPUT
fi
- name: Update date in CHANGELOG.md
if: ${{ steps.check_unreleased.outputs.UNRELEASED_FOUND == 'true' }}
shell: bash
run: |
if [ "${{ github.event.inputs.date }}" = "today" ]; then
RELEASE_DATE=$(date +%Y-%m-%d)
else
RELEASE_DATE=${{ github.event.inputs.date }}
fi
sed -i "s/unreleased/${RELEASE_DATE}/" CHANGELOG.md
- name: Commit / Push CHANGELOG.md
if: ${{ steps.check_unreleased.outputs.UNRELEASED_FOUND == 'true' }}
env:
GH_TOKEN: ${{ secrets.github_token }}
COMMIT: "ci: automatic changelog update for release"
shell: bash
run: |
git config --local user.name github-actions[bot]
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
if git show-ref --quiet refs/heads/${{ env.BRANCH }}; then
echo "Branch ${{ env.BRANCH }} already exists."
git branch -D "${{ env.BRANCH }}"
git push origin --delete "${{ env.BRANCH }}"
fi
git checkout -b "${{ env.BRANCH }}"
git add CHANGELOG.md || echo "No changes to add"
git commit -m "${{ env.COMMIT }}" || echo "No changes to commit"
git push --force origin ${{ env.BRANCH }} || echo "No changes to push"
- name: Create Pull Request
if: ${{ steps.check_unreleased.outputs.UNRELEASED_FOUND == 'true' }}
shell: bash
run: |
sleep 30
gh pr create --fill-first --base "main" --head "${{ env.BRANCH }}" --label "Type: CI/CD :robot:"
- name: Merge Pull Request
if: ${{ steps.check_unreleased.outputs.UNRELEASED_FOUND == 'true' }}
shell: bash
run: |
sleep 30
gh pr merge --auto --squash --delete-branch
release-publish:
runs-on: ubuntu-latest
needs: update-changelog
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
shell: bash
run: npm install
- name: Install Visual Studio Code Extension Manager
shell: bash
run: npm install -g @vscode/vsce
- name: Set version
shell: bash
run: |
echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Set changelog
env:
VERSION: ${{ env.VERSION }}
shell: bash
run: |
awk -v version="^## ${VERSION}.*" '
$0 ~ version {flag=1; next}
/^## / && flag {flag=0}
flag
' CHANGELOG.md >"CHANGELOG-${VERSION}.md"
echo "CHANGELOG=CHANGELOG-${VERSION}.md" >> $GITHUB_ENV
- name: Package extension
env:
GH_TOKEN: ${{ secrets.github_token }}
VERSION: ${{ env.VERSION }}
CHANGELOG: ${{ env.CHANGELOG }}
shell: bash
run: |
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
vsce package --pre-release
gh release create ${VERSION} ./quarto-wizard-${VERSION}.vsix --prerelease --title ${VERSION} --notes-file ${CHANGELOG} --generate-notes
else
vsce package
gh release create ${VERSION} ./quarto-wizard-${VERSION}.vsix --title ${VERSION} --notes-file ${CHANGELOG} --generate-notes
fi
- name: Publish extension to Visual Studio Marketplace
env:
VS_MARKETPLACE_TOKEN: ${{ secrets.VS_MARKETPLACE_TOKEN }}
shell: bash
run: |
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
vsce publish --pre-release --pat ${VS_MARKETPLACE_TOKEN}
else
vsce publish --pat ${VS_MARKETPLACE_TOKEN}
fi
- name: Publish extension to Open VSX Registry
env:
OPEN_VSX_REGISTRY_TOKEN: ${{ secrets.OPEN_VSX_REGISTRY_TOKEN }}
shell: bash
run: |
npm install --global ovsx
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
npx ovsx publish --pre-release --pat ${OPEN_VSX_REGISTRY_TOKEN}
else
npx ovsx publish --pat ${OPEN_VSX_REGISTRY_TOKEN}
fi