vscode-ruby-lsp-v0.8.14 #52
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
release: | |
types: [published] | |
jobs: | |
publish: | |
if: ${{ startsWith(github.ref, 'refs/tags/vscode-ruby-lsp') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout | |
- uses: actions/setup-node@v4 | |
name: Use Node.js | |
env: | |
DISABLE_V8_COMPILE_CACHE: "1" | |
with: | |
node-version: "20.9" | |
cache: "yarn" | |
cache-dependency-path: "vscode" | |
- name: Update release notes | |
uses: actions/github-script@v7 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
script: | | |
const { data } = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const previousRelease = data.find((release) => release.tag_name.startsWith("vscode-ruby-lsp") && release.tag_name !== "${{ github.ref_name }}"); | |
const commitResponse = await github.rest.repos.compareCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
base: previousRelease.tag_name, | |
head: "${{ github.ref_name }}" | |
}); | |
console.log(`Found ${commitResponse.data.commits.length} commits`); | |
const pullRequests = []; | |
for (const commit of commitResponse.data.commits) { | |
const pullsResponse = await github.request(`GET /repos/shopify/ruby-lsp/commits/${commit.sha}/pulls`); | |
pullsResponse.data.forEach((pr) => { | |
if (!pullRequests.some((pull) => pull.url === pr.html_url)) { | |
pullRequests.push({ | |
title: pr.title, | |
url: pr.html_url, | |
labels: pr.labels.map((label) => label.name), | |
author: pr.user.login | |
}); | |
} | |
}); | |
} | |
console.log(`Found ${pullRequests.length} pull requests`); | |
const relevantPulls = pullRequests.filter((pull) => { | |
return pull.labels.some((label) => label === "vscode") && | |
!pull.labels.some((label) => label === "dependencies") && | |
!pull.labels.some((label) => label === "chore") | |
}); | |
const breakingChanges = relevantPulls.filter((pull) => pull.labels.some((label) => label === "breaking-change")); | |
const bugFixes = relevantPulls.filter((pull) => pull.labels.some((label) => label === "bugfix")); | |
const enhancements = relevantPulls.filter((pull) => pull.labels.some((label) => label === "enhancement")); | |
const otherChanges = relevantPulls.filter((pull) => !pull.labels.some((label) => ["bugfix", "enhancement", "breaking-change"].includes(label))); | |
let content = `# ${{ github.ref_name }}\n`; | |
if (breakingChanges.length > 0) { | |
content += `## 🚧 Breaking Changes\n\n${breakingChanges.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`; | |
} | |
if (enhancements.length > 0) { | |
content += `## ✨ Enhancements\n\n${enhancements.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`; | |
} | |
if (bugFixes.length > 0) { | |
content += `## 🐛 Bug Fixes\n\n${bugFixes.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`; | |
} | |
if (otherChanges.length > 0) { | |
content += `## 📦 Other Changes\n\n${otherChanges.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`; | |
} | |
const releaseResponse = await github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: "${{ github.ref_name }}", | |
}); | |
await github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: releaseResponse.data.id, | |
body: content | |
}); | |
- name: Create CHANGELOG.md | |
uses: actions/github-script@v7 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
script: | | |
const fs = require("fs"); | |
const { data: releases } = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const includePrereleases = context.payload.release.prerelease; | |
const changelog = releases | |
.filter((release) => release.tag_name.startsWith("vscode-ruby-lsp") && (includePrereleases || !release.prerelease)) | |
.map((release) => `${release.body}\n`) | |
.join("\n"); | |
fs.writeFileSync("vscode/CHANGELOG.md", changelog); | |
- name: Copy files needed for release | |
run: | | |
cp CODE_OF_CONDUCT.md vscode/CODE_OF_CONDUCT.md | |
- name: 📦 Install dependencies | |
working-directory: ./vscode | |
run: yarn --frozen-lockfile | |
# Stable releases | |
- name: Publish extension in the marketplace | |
if: "!github.event.release.prerelease" | |
working-directory: ./vscode | |
run: | | |
yarn run package | |
node_modules/.bin/vsce publish --packagePath vscode-ruby-lsp.vsix | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
# Prereleases | |
- name: Package and publish prerelease extension in the marketplace | |
if: "github.event.release.prerelease" | |
working-directory: ./vscode | |
run: | | |
yarn run package_prerelease | |
node_modules/.bin/vsce publish --pre-release --packagePath vscode-ruby-lsp.vsix | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
# Stable releases for OpenVSX | |
- name: Publish extension on OpenVSX | |
if: "!github.event.release.prerelease" | |
working-directory: ./vscode | |
run: | | |
yarn run package | |
node_modules/.bin/ovsx publish vscode-ruby-lsp.vsix -p ${{ secrets.OPENVSX_TOKEN }} --yarn |