ci: improved release flow

This commit is contained in:
alina 🌸 2024-03-24 01:31:44 +03:00
parent 31e3cca538
commit 669685ed40
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 32 additions and 8 deletions

View file

@ -35,6 +35,8 @@ jobs:
git config user.name "mtcute-bot"
git config user.email mtcute-bot@tei.su
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- name: Verify NPM token
run: npm whoami
- name: Find packages to publish
id: find
run: node scripts/find-updated-packages.js ${{ inputs.kind }} ${{ inputs.packages }}
@ -44,15 +46,15 @@ jobs:
- name: Bump versions
id: bump
run: node scripts/bump-version.js ${{ inputs.kind }} ${{ steps.find.outputs.modified }}
- name: Commit version bumps
run: |
git commit -am "v${{ steps.bump.outputs.version }}"
git push
- name: Build packages and publish to NPM
id: build
env:
GH_RELEASE: 1
run: node scripts/publish.js ${{ steps.find.outputs.modified }}
- name: Commit version bumps
run: |
git commit -am "v${{ steps.bump.outputs.version }}"
git push
- name: GitHub Release
uses: ncipollo/release-action@v1
with:

View file

@ -91,6 +91,7 @@ async function main(arg = process.argv[2]) {
console.log('[i] Using registry %s', REGISTRY)
const publishedPkgs = []
const failedPkgs = []
if (arg === 'all' || arg === 'updated') {
for (const pkg of listPackages()) {
@ -102,16 +103,37 @@ async function main(arg = process.argv[2]) {
continue
}
await publishSinglePackage(pkg)
publishedPkgs.push(pkg)
try {
await publishSinglePackage(pkg)
publishedPkgs.push(pkg)
} catch (e) {
console.error('[!] Failed to publish %s:', pkg)
console.error(e)
failedPkgs.push(pkg)
}
}
} else {
for (const pkg of arg.split(',')) {
await publishSinglePackage(pkg)
publishedPkgs.push(pkg)
try {
await publishSinglePackage(pkg)
publishedPkgs.push(pkg)
} catch (e) {
console.error('[!] Failed to publish %s:', pkg)
console.error(e)
failedPkgs.push(pkg)
}
}
}
if (failedPkgs.length > 0) {
console.error('[!] Failed to publish packages:')
for (const pkg of failedPkgs) {
console.error(' - %s', pkg)
}
process.exit(1)
}
if (process.env.GH_RELEASE) {
// we should also generate tgz files for all published packages
// for a github release, and also generate a title