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
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
actions: read
outputs:
manifest-sha256: ${{ steps.package.outputs.manifest_sha256 }}
artifact-id: ${{ steps.upload.outputs.artifact-id }}
env:
RELEASE_VERSION: ${{ inputs.version }}
RELEASE_COMMIT: ${{ inputs.commit }}
Expand All @@ -50,7 +51,8 @@ jobs:
- run: npm ci --ignore-scripts --no-audit --no-fund
- id: package
run: node scripts/release.mjs prepare "$RUNNER_TEMP/release"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- id: upload
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: npm-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/release/
Expand Down Expand Up @@ -83,7 +85,7 @@ jobs:
- run: npm install --global npm@11.19.1 --ignore-scripts --no-audit --no-fund
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: npm-${{ github.run_id }}-${{ github.run_attempt }}
artifact-ids: ${{ needs.package.outputs.artifact-id }}
path: ${{ runner.temp }}/release
- run: node scripts/release.mjs publish "$RUNNER_TEMP/release"
env:
Expand Down
11 changes: 11 additions & 0 deletions test/release.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ const environment = { can_admins_bypass: false,
deployment_branch_policy: { custom_branch_policies: true, protected_branches: false } };
const policies = { total_count: 1, branch_policies: [{ name: 'main', type: 'branch' }] };

test('publish reruns download the artifact from the successful package job', () => {
const workflow = fs.readFileSync(new URL('../.github/workflows/release.yml', import.meta.url), 'utf8');
const [packageJob, publishJob] = workflow.slice(workflow.indexOf('\n package:\n')).split('\n publish:\n');
assert.match(packageJob, /artifact-id: \$\{\{ steps\.upload\.outputs\.artifact-id \}\}/);
assert.match(packageJob, /- id: upload\n uses: actions\/upload-artifact@/);
const download = publishJob.match(/uses: actions\/download-artifact@[^\n]+\n with:\n((?: {10}[^\n]+\n)+)/)?.[1];
assert.ok(download, 'Download step must exist');
assert.match(download, /artifact-ids: \$\{\{ needs\.package\.outputs\.artifact-id \}\}/);
assert.doesNotMatch(download, /(?:^|\n) {10}name:/);
});

test('release identity requires a manually dispatched reviewed main commit and stable matching version', () => {
validateSource(env, pkg);
for (const [key, value] of Object.entries({ GITHUB_EVENT_NAME: 'push', GITHUB_REPOSITORY: 'other/nstdata-proxy-sdk-node', GITHUB_REF: 'refs/heads/feature',
Expand Down
Loading