-
Notifications
You must be signed in to change notification settings - Fork 442
167 lines (148 loc) · 5.35 KB
/
release.yml
File metadata and controls
167 lines (148 loc) · 5.35 KB
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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version bump (or explicit semver, e.g. 5.0.0-rc.2)'
required: true
default: 'prerelease'
type: string
target:
description: 'Where to publish'
required: true
default: 'both'
type: choice
options:
- both
- vsce
- ovsx
- dry-run
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: r5n-m2-ultra
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install
run: bun install --frozen-lockfile
- name: Lint
run: bun run lint
- name: Typescript
run: bun run typescript
- name: Configure git
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Bump version
if: github.event_name == 'workflow_dispatch'
id: bump
env:
VERSION_INPUT: ${{ github.event.inputs.version }}
run: |
set -euo pipefail
if ! [[ "$VERSION_INPUT" =~ ^(major|minor|patch|prerelease|premajor|preminor|prepatch)$ ]] \
&& ! [[ "$VERSION_INPUT" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Invalid version input: $VERSION_INPUT"
exit 1
fi
case "$VERSION_INPUT" in
major|minor|patch|prerelease|premajor|preminor|prepatch)
NEW_VERSION=$(npm version "$VERSION_INPUT" --no-git-tag-version --preid=rc | tr -d 'v')
;;
*)
NEW_VERSION=$(npm version "$VERSION_INPUT" --no-git-tag-version | tr -d 'v')
;;
esac
printf 'version=%s\n' "$NEW_VERSION" >> "$GITHUB_OUTPUT"
printf 'tag=v%s\n' "$NEW_VERSION" >> "$GITHUB_OUTPUT"
git add package.json
git commit -m "chore(release): v${NEW_VERSION}"
git tag "v${NEW_VERSION}"
- name: Resolve version (tag push)
if: github.event_name == 'push'
id: tag
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Tag $TAG does not match v<semver>"
exit 1
fi
printf 'version=%s\n' "${TAG#v}" >> "$GITHUB_OUTPUT"
printf 'tag=%s\n' "$TAG" >> "$GITHUB_OUTPUT"
- name: Set version output
id: version
env:
DISPATCH_VERSION: ${{ steps.bump.outputs.version }}
DISPATCH_TAG: ${{ steps.bump.outputs.tag }}
TAG_VERSION: ${{ steps.tag.outputs.version }}
TAG_TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
printf 'version=%s\n' "$DISPATCH_VERSION" >> "$GITHUB_OUTPUT"
printf 'tag=%s\n' "$DISPATCH_TAG" >> "$GITHUB_OUTPUT"
else
printf 'version=%s\n' "$TAG_VERSION" >> "$GITHUB_OUTPUT"
printf 'tag=%s\n' "$TAG_TAG" >> "$GITHUB_OUTPUT"
fi
- name: Compile
run: bun run compile
- name: Package vsix
run: bun run package
- name: Detect prerelease
id: prerelease
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
if [[ "$VERSION" == *-* ]]; then
printf 'flag=--pre-release\n' >> "$GITHUB_OUTPUT"
printf 'is_prerelease=true\n' >> "$GITHUB_OUTPUT"
else
printf 'flag=\n' >> "$GITHUB_OUTPUT"
printf 'is_prerelease=false\n' >> "$GITHUB_OUTPUT"
fi
- name: Publish to VS Code Marketplace
if: github.event_name == 'push' || github.event.inputs.target == 'both' || github.event.inputs.target == 'vsce'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
PRERELEASE_FLAG: ${{ steps.prerelease.outputs.flag }}
run: bunx vsce publish $PRERELEASE_FLAG --no-dependencies
- name: Publish to Open VSX
if: github.event_name == 'push' || github.event.inputs.target == 'both' || github.event.inputs.target == 'ovsx'
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
PRERELEASE_FLAG: ${{ steps.prerelease.outputs.flag }}
run: bunx ovsx publish $PRERELEASE_FLAG --no-dependencies
- name: Push commit + tag
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target != 'dry-run'
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
git push origin HEAD
git push origin "$RELEASE_TAG"
- name: Create GitHub Release
if: github.event.inputs.target != 'dry-run'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
generate_release_notes: true
files: '*.vsix'