Skip to content

Commit 7eb2eb7

Browse files
authored
Refactor release workflows (#3911)
* Refactor release workflows * Match VS Code's NodeJS version
1 parent e25d484 commit 7eb2eb7

5 files changed

Lines changed: 115 additions & 217 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
DISABLE_V8_COMPILE_CACHE: "1"
1414
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
1515
with:
16-
node-version: "22.15"
16+
node-version: "22.21"
1717

1818
- name: Run cspell
1919
run: |
@@ -72,7 +72,7 @@ jobs:
7272
DISABLE_V8_COMPILE_CACHE: "1"
7373
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
7474
with:
75-
node-version: "22.15"
75+
node-version: "22.21"
7676
cache: "yarn"
7777
cache-dependency-path: "vscode"
7878

@@ -96,7 +96,7 @@ jobs:
9696
env:
9797
DISABLE_V8_COMPILE_CACHE: 1
9898
with:
99-
node-version: "22.15"
99+
node-version: "22.21"
100100
cache: "yarn"
101101
cache-dependency-path: "vscode"
102102

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: Publish
1+
name: Release VS Code extension
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
tags:
6+
- vscode-ruby-lsp-v[0-9]+.[0-9]+.[0-9]+(-preview)?
67

78
jobs:
8-
publish:
9-
if: ${{ startsWith(github.ref, 'refs/tags/vscode-ruby-lsp') }}
9+
release_extension:
10+
if: github.repository == 'Shopify/ruby-lsp'
1011
runs-on: ubuntu-latest
1112

1213
steps:
@@ -18,11 +19,74 @@ jobs:
1819
env:
1920
DISABLE_V8_COMPILE_CACHE: "1"
2021
with:
21-
node-version: "22.15"
22+
node-version: "22.21"
2223
cache: "yarn"
2324
cache-dependency-path: "vscode"
2425

25-
- name: Update release notes
26+
- name: Create CHANGELOG.md
27+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
28+
with:
29+
github-token: "${{ secrets.GITHUB_TOKEN }}"
30+
script: |
31+
const fs = require("fs");
32+
33+
const { data: releases } = await github.rest.repos.listReleases({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
});
37+
38+
const includePrereleases = context.payload.release.prerelease;
39+
40+
const changelog = releases
41+
.filter((release) => release.tag_name.startsWith("vscode-ruby-lsp") && (includePrereleases || !release.prerelease))
42+
.map((release) => `${release.body}\n`)
43+
.join("\n");
44+
45+
fs.writeFileSync("vscode/CHANGELOG.md", changelog);
46+
47+
- name: Copy files needed for release
48+
run: |
49+
cp CODE_OF_CONDUCT.md vscode/CODE_OF_CONDUCT.md
50+
51+
- name: 📦 Install dependencies
52+
working-directory: ./vscode
53+
run: yarn --frozen-lockfile
54+
55+
# Stable releases
56+
- name: Publish extension in the marketplace
57+
if: ${{ !endsWith(github.ref_name, '-preview') }}
58+
working-directory: ./vscode
59+
run: |
60+
yarn run package
61+
node_modules/.bin/vsce publish --packagePath vscode-ruby-lsp.vsix
62+
env:
63+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
64+
65+
# Prereleases
66+
- name: Package and publish prerelease extension in the marketplace
67+
if: ${{ endsWith(github.ref_name, '-preview') }}
68+
working-directory: ./vscode
69+
run: |
70+
yarn run package_prerelease
71+
node_modules/.bin/vsce publish --pre-release --packagePath vscode-ruby-lsp.vsix
72+
env:
73+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
74+
75+
# Stable releases for OpenVSX
76+
- name: Publish extension on OpenVSX
77+
if: ${{ !endsWith(github.ref_name, '-preview') }}
78+
working-directory: ./vscode
79+
run: |
80+
yarn run package
81+
node_modules/.bin/ovsx publish vscode-ruby-lsp.vsix -p ${{ secrets.OPENVSX_TOKEN }} --yarn
82+
83+
release_github:
84+
name: Create GitHub release
85+
if: github.repository == 'Shopify/ruby-lsp'
86+
needs: release_extension
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Create GitHub release
2690
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
2791
with:
2892
github-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -88,72 +152,11 @@ jobs:
88152
content += `## 📦 Other Changes\n\n${otherChanges.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`;
89153
}
90154
91-
const releaseResponse = await github.rest.repos.getReleaseByTag({
92-
owner: context.repo.owner,
93-
repo: context.repo.repo,
94-
tag: "${{ github.ref_name }}",
95-
});
96-
97-
await github.rest.repos.updateRelease({
98-
owner: context.repo.owner,
99-
repo: context.repo.repo,
100-
release_id: releaseResponse.data.id,
101-
body: content
102-
});
103-
104-
- name: Create CHANGELOG.md
105-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
106-
with:
107-
github-token: "${{ secrets.GITHUB_TOKEN }}"
108-
script: |
109-
const fs = require("fs");
110-
111-
const { data: releases } = await github.rest.repos.listReleases({
155+
await github.rest.repos.createRelease({
112156
owner: context.repo.owner,
113157
repo: context.repo.repo,
158+
tag_name: "${{ github.ref }}",
159+
name: "${{ github.ref_name }}",
160+
body: content,
161+
prerelease: "${{ github.ref_name }}".endsWith("-preview")
114162
});
115-
116-
const includePrereleases = context.payload.release.prerelease;
117-
118-
const changelog = releases
119-
.filter((release) => release.tag_name.startsWith("vscode-ruby-lsp") && (includePrereleases || !release.prerelease))
120-
.map((release) => `${release.body}\n`)
121-
.join("\n");
122-
123-
fs.writeFileSync("vscode/CHANGELOG.md", changelog);
124-
125-
- name: Copy files needed for release
126-
run: |
127-
cp CODE_OF_CONDUCT.md vscode/CODE_OF_CONDUCT.md
128-
129-
- name: 📦 Install dependencies
130-
working-directory: ./vscode
131-
run: yarn --frozen-lockfile
132-
133-
# Stable releases
134-
- name: Publish extension in the marketplace
135-
if: "!github.event.release.prerelease"
136-
working-directory: ./vscode
137-
run: |
138-
yarn run package
139-
node_modules/.bin/vsce publish --packagePath vscode-ruby-lsp.vsix
140-
env:
141-
VSCE_PAT: ${{ secrets.VSCE_PAT }}
142-
143-
# Prereleases
144-
- name: Package and publish prerelease extension in the marketplace
145-
if: "github.event.release.prerelease"
146-
working-directory: ./vscode
147-
run: |
148-
yarn run package_prerelease
149-
node_modules/.bin/vsce publish --pre-release --packagePath vscode-ruby-lsp.vsix
150-
env:
151-
VSCE_PAT: ${{ secrets.VSCE_PAT }}
152-
153-
# Stable releases for OpenVSX
154-
- name: Publish extension on OpenVSX
155-
if: "!github.event.release.prerelease"
156-
working-directory: ./vscode
157-
run: |
158-
yarn run package
159-
node_modules/.bin/ovsx publish vscode-ruby-lsp.vsix -p ${{ secrets.OPENVSX_TOKEN }} --yarn
Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
name: Release
1+
name: Release gem on RubyGems.org and create GitHub release
22

33
on:
44
push:
55
tags:
66
- v[0-9]+.[0-9]+.[0-9]+
77

88
jobs:
9-
publish:
9+
release_gem:
10+
name: Release gem on RubyGems.org
11+
if: github.repository == 'Shopify/ruby-lsp'
1012
runs-on: ubuntu-latest
1113

14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
environment: release
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
23+
with:
24+
persist-credentials: false
25+
26+
- name: Set up Ruby
27+
uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0
28+
with:
29+
bundler-cache: true
30+
31+
- name: Release gem on RubyGems.org
32+
uses: rubygems/release-gem@1c162a739e8b4cb21a676e97b087e8268d8fc40b # v1.1.2
33+
34+
release_github:
35+
name: Create GitHub release
36+
if: github.repository == 'Shopify/ruby-lsp'
37+
needs: release_gem
38+
runs-on: ubuntu-latest
39+
40+
permissions:
41+
contents: write
42+
1243
steps:
13-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
14-
name: Checkout
44+
- name: Checkout repository
45+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1546

1647
- name: Create release
1748
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0

.github/workflows/version_bump.yml

Lines changed: 0 additions & 136 deletions
This file was deleted.

dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ up:
99
- bundler
1010
- node:
1111
yarn: true
12-
version: 22.15.1
12+
version: 22.21.1
1313
packages:
1414
- vscode
1515
- packages:

0 commit comments

Comments
 (0)