Skip to content

Commit

Permalink
Add WIP pre-release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc committed Aug 21, 2023
1 parent 4c702ac commit 1fb0019
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 68 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/bump-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import latestSemver from 'latest-semver'
import * as fs from 'fs/promises'
import assert from 'assert'

async function bumpVersion() {
let res = await fetch(
'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery',
{
method: 'POST',
headers: {
accept: 'application/json;api-version=7.2-preview.1;excludeUrls=true',
'content-type': 'application/json',
},
body: JSON.stringify({
assetTypes: null,
flags: 2151,
filters: [
{
criteria: [{ filterType: 7, value: 'bradlc.vscode-tailwindcss' }],
direction: 2,
pageSize: 100,
pageNumber: 1,
sortBy: 0,
sortOrder: 0,
pagingToken: null,
},
],
}),
}
)
let { results } = await res.json()
let versions = results[0].extensions[0].versions.map(({ version }) => version)
let latest = latestSemver(versions)
let parts = latest.split('.')

assert(Number(parts[1]) % 2 === 1)

let nextVersion = `${parts[0]}.${parts[1]}.${Number(parts[2]) + 1}`
let pkgFilename = 'packages/vscode-tailwindcss/package.json'
let pkg = JSON.parse(await fs.readFile(pkgFilename, 'utf8'))
await fs.writeFile(pkgFilename, JSON.stringify({ ...pkg, version: nextVersion }, null, 2), 'utf8')
}

bumpVersion()
38 changes: 38 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish pre-release
concurrency: publish
on:
push:
branches: [master]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install && npm run bootstrap
- name: Bump version
run: >
node .github/workflows/bump-version.mjs &&
cat packages/vscode-tailwindcss/package.json
# - name: Publish
# env:
# VSCODE_TOKEN: ${{ secrets.VSCODE_TOKEN }}
# run: npx lerna run publish --scope=vscode-tailwindcss -- --pre-release -p $VSCODE_TOKEN
- name: Build LSP
run: npx lerna run build --scope=tailwindcss-language-server
- name: Resolve LSP version
run: |
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: 'Version LSP based on commit: 0.0.0-insiders.${{ env.SHA_SHORT }}'
run: >
cd packages/tailwindcss-language-server &&
npm version 0.0.0-insiders.${{ env.SHA_SHORT }} --force --no-git-tag-version
- name: Publish LSP
run: >
cd packages/tailwindcss-language-server &&
npm publish --tag insiders
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading

0 comments on commit 1fb0019

Please sign in to comment.