diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae311ee..2b20aea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} @@ -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/ @@ -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: diff --git a/test/release.test.mjs b/test/release.test.mjs index 9aa0765..cd2afc1 100644 --- a/test/release.test.mjs +++ b/test/release.test.mjs @@ -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',