Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/node-gha/src/publish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'path'
import fs from 'fs/promises'
import {
describe,
expect,
Expand Down Expand Up @@ -49,6 +50,30 @@ describe('node-gha', () => {
expect(await project.gitClient.getCurrentBranch()).toBe('master')
})

it('should stage GitHub Action files without build commands', async () => {
const { cwd } = await forkProject('node-gha-publish-existing-files', packageJsonProject({
version: '2.5.0',
files: [
'dist'
]
}))
const remote = await createDirectory('node-gha-publish-existing-files-remote')
const project = new NodeGhaProject({
path: join(cwd, 'package.json')
})

await fs.mkdir(join(cwd, 'dist'), {
recursive: true
})
await fs.writeFile(join(cwd, 'dist/index.js'), 'existing\n')
await project.gitClient.exec('-C', remote, 'init', '--bare')
await project.gitClient.exec('remote', 'set-url', 'origin', remote)

await project.publish()

expect(await project.gitClient.exec('show', 'v2.5.0:dist/index.js')).toBe('existing')
})
Comment thread
dangreen marked this conversation as resolved.

it('should use custom ref names and explicit files', async () => {
const { cwd } = await forkProject('node-gha-publish-custom-refs', packageJsonProject({
version: '3.0.0'
Expand Down
4 changes: 2 additions & 2 deletions packages/node-gha/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export async function publish(project: PackageJsonProject, options: PublishOptio

await runBuildCommands(buildCommands, options, projectPath)

if (!dryRun && buildCommands.length && files.length) {
logger?.info('Staging built GitHub Action files...')
if (!dryRun && files.length) {
logger?.info('Staging GitHub Action files...')

await gitClient.exec('add', '--force', '--', ...files)

Expand Down