-
-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (128 loc) · 4.58 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
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
permissions:
contents: write
jobs:
update-changelog:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
BRANCH: ci/update-changelog-release
GITHUB_TOKEN: ${{ secrets.github_token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update date in CHANGELOG.md
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
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
shell: bash
run: |
sleep 30
gh pr create --fill-first --base "main" --head "${{ env.BRANCH }}" --label "Type: CI/CD :robot:" || echo "No changes to commit"
- name: Merge Pull Request
shell: bash
run: |
sleep 30
gh pr merge --auto --squash --delete-branch || echo "No changes to merge"
release-publish:
runs-on: ubuntu-latest
needs: update-changelog
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