Skip to content

Commit 7ead6d9

Browse files
committed
chore: use core.setOutput
1 parent 8cdeb05 commit 7ead6d9

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "It is used to get the hash of the [Prisma Rust Engines](https://github.com/prisma/prisma-engines) for downloading via the [Prisma CLI, the Client](https://github.com/prisma/prisma), and other tooling.",
55
"private": true,
66
"devDependencies": {
7+
"@actions/core": "1.10.0",
78
"@sindresorhus/slugify": "1.1.2",
89
"@types/node": "18.16.0",
910
"@types/node-fetch": "2.6.3",

pnpm-lock.yaml

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/publish.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { AssertionError } from 'assert'
44
import chalk from 'chalk'
55
import execa from 'execa'
66
import fs from 'fs'
7-
import os from 'os'
87
import fetch from 'node-fetch'
8+
import * as core from '@actions/core'
99

1010
/**
1111
* Turns a prisma-engines Git branch name (that got new engines published) into a
@@ -49,16 +49,20 @@ async function main(dryRun = false) {
4949
npmDistTag === 'integration'
5050
? `${slugify(githubEventClientPayload.branch)}-`
5151
: ''
52-
const nextStable = await getNextPrismaStableVersion(npmDistTag === 'patch')
53-
const versionIncrement = await getNextVersionIncrement(nextStable)
52+
const nextStable = await getNextPrismaStableVersion({
53+
isPatch: npmDistTag === 'patch',
54+
})
55+
const versionIncrement = await getNextVersionIncrement({
56+
versionPrefix: nextStable,
57+
})
5458
const newVersion = `${nextStable}-${versionIncrement}.${optionalNamePart}${githubEventClientPayload.commit}`
5559

5660
console.log(chalk.bold.greenBright('Going to publish:\n'))
5761
console.log(`${chalk.bold('New version')} ${newVersion}`)
5862
console.log(`${chalk.bold('Npm Dist Tag')} ${npmDistTag}\n`)
5963
// Set GITHUB_OUTPUT
60-
setOutput('new_prisma_version', newVersion)
61-
setOutput('npm_dist_tag', npmDistTag)
64+
core.setOutput('new_prisma_version', newVersion)
65+
core.setOutput('npm_dist_tag', npmDistTag)
6266

6367
// @prisma/engines-version
6468
adjustPkgJson('packages/engines-version/package.json', (pkg) => {
@@ -86,9 +90,11 @@ function setPatchZero(version: string): string {
8690
}
8791

8892
/** Get next stable version of prisma CLI (using Npm) */
89-
async function getNextPrismaStableVersion(
90-
isPatch: boolean,
91-
): Promise<string | null> {
93+
async function getNextPrismaStableVersion({
94+
isPatch,
95+
}: {
96+
isPatch: boolean
97+
}): Promise<string | null> {
9298
const data = await fetch('https://registry.npmjs.org/prisma').then((res) =>
9399
res.json(),
94100
)
@@ -102,7 +108,11 @@ async function getNextPrismaStableVersion(
102108
}
103109

104110
/** Get next version increment of engines version (using Npm) */
105-
async function getNextVersionIncrement(versionPrefix: string): Promise<number> {
111+
async function getNextVersionIncrement({
112+
versionPrefix,
113+
}: {
114+
versionPrefix: string
115+
}): Promise<number> {
106116
console.log('getting increment for prefix', versionPrefix)
107117
const data = await fetch(
108118
'https://registry.npmjs.org/@prisma/engines-version',
@@ -230,13 +240,6 @@ async function run(
230240
}
231241
}
232242

233-
// From https://github.com/actions/toolkit/issues/1218#issuecomment-1288890856
234-
function setOutput(key, value) {
235-
// Temporary hack until core actions library catches up with github new recommendations
236-
const output = process.env['GITHUB_OUTPUT']
237-
fs.appendFileSync(output, `${key}=${value}${os.EOL}`)
238-
}
239-
240243
// useful for debugging
241244
// process.env.GITHUB_EVENT_CLIENT_PAYLOAD = JSON.stringify({
242245
// branch: 'enabling-node-api',

0 commit comments

Comments
 (0)