Skip to content

Commit

Permalink
Update release CI
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Aug 27, 2024
1 parent d77a172 commit 5cd6674
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 49 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,40 @@ function getNextVersion(version) {
return `${stableVersion}.post${parseInt(post, 10) + 1}`
}

async function extractVersions() {
core.setOutput('stubs-version', '')
const package = process.env.PACKAGE
const stubsPackage = process.env.STUBS
const force = context.payload.inputs ? context.payload.inputs.force !== 'false' : false

if (force) {
core.notice('Force release, skipping version check')
}

const inputVersion = context.payload.inputs?.version
const version = inputVersion ? inputVersion : await getLatestVersion(package)
core.notice(`${package} version = ${version}`)

const stubsVersion = await getLatestStubsVersion(stubsPackage, version)
core.notice(`${stubsPackage} latest version = ${stubsVersion}`)

const buildStubsVersion = stubsVersion ? getNextVersion(stubsVersion) : version

if (!force) {
const isStubsVersionGreater = stubsVersion === null || isStableVersionGreater(buildStubsVersion, stubsVersion)
if (!isStubsVersionGreater) {
core.notice('Stubs version is not greater than the latest, skipping run')
return
}
}

core.notice(`New ${package} version found: ${version}`)
core.notice(`${stubsPackage} build version = ${buildStubsVersion}`)
core.setOutput('version', version)
core.setOutput('stubs-version', buildStubsVersion)
}

module.exports = {
setupGlobals,
getLatestVersion,
getLatestStubsVersion,
isStableVersionGreater,
getNextVersion
extractVersions
}
52 changes: 7 additions & 45 deletions .github/workflows/publish_on_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
required: false
default: false
type: boolean
description: Force build even if stubs are published
description: Force build even if consistency check fails (set to true)
version:
required: false
default: ""
Expand All @@ -26,57 +26,19 @@ jobs:
name: Check version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.result }}
stubs-version: ${{ steps.stubs-version.outputs.result }}
version: ${{ steps.vars.outputs.version }}
stubs-version: ${{ steps.vars.outputs.stubs-version }}
steps:
- uses: actions/checkout@v4
- name: Extract version
id: version
- name: Extract versions
id: vars
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { setupGlobals, extractVersions, getLatestVersion } = require('./.github/workflows/helpers.js')
const { setupGlobals, extractVersions } = require('./.github/workflows/helpers.js')
setupGlobals({ fetch, core, context })
const package = process.env.PACKAGE
const inputVersion = context.payload.inputs?.version
const version = inputVersion ? inputVersion : await getLatestVersion(package)
core.notice(`${package} version = ${version}`)
return version
- name: Extract stubs version
id: stubs-version
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { setupGlobals, isStableVersionGreater, getLatestStubsVersion, getLatestVersion, getNextVersion } = require('./.github/workflows/helpers.js')
setupGlobals({ fetch, core, context })
const stubsPackage = process.env.STUBS
const force = context.payload.inputs ? context.payload.inputs.force !== 'false' : false
const version = "${{ steps.version.outputs.result }}"
if (force) {
core.notice('Force release, skipping version check')
}
const stubsVersion = await getLatestStubsVersion(stubsPackage, version)
core.notice(`${stubsPackage} latest version = ${stubsVersion}`)
const buildStubsVersion = stubsVersion ? getNextVersion(stubsVersion) : version
const isStubsVersionGreater = stubsVersion === null || isStableVersionGreater(buildStubsVersion, stubsVersion)
if (!isStubsVersionGreater && !force) {
core.notice('Stubs version is not greater than the latest, skipping run')
return ''
}
core.notice(`${stubsPackage} build version = ${buildStubsVersion}`)
return buildStubsVersion
await extractVersions()
publish-stubs:
name: Publish stubs
Expand Down

0 comments on commit 5cd6674

Please sign in to comment.