Skip to content

Commit c903292

Browse files
add generic signing action
1 parent aeef73c commit c903292

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

node/sign_js_only_package/action.yml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Compress, Sign and Upload to GH Release
22
description: 'Compresses package and signs with garasign and uploads to GH release'
33

4-
inputs:
4+
inputs:
55
aws_role_arn:
66
description: 'AWS role input for drivers-github-tools/gpg-sign@v2'
77
required: true
@@ -12,45 +12,80 @@ inputs:
1212
description: 'AWS secret id input for drivers-github-tools/gpg-sign@v2'
1313
required: true
1414
npm_package_name:
15-
description: the npm package name
15+
description: 'The name for the npm package this repository represents'
1616
required: true
1717
dry_run:
1818
description: 'Should we upload files to the release?'
1919
required: false
2020
default: 'true'
21+
artifact_directory:
22+
description: The directory in which to output signatures.
23+
required: true
24+
sign_native:
25+
description: Download and sign native packages
26+
default: "false"
2127

2228
runs:
2329
using: composite
2430
steps:
31+
- uses: actions/download-artifact@v4
32+
if: ${{ inputs.sign_native == 'true' }}
33+
2534
- run: npm pack
2635
shell: bash
2736

28-
- name: Determine version and package info
37+
- name: Make signatures directory
38+
shell: bash
39+
run: mkdir ${{ inputs.artifact_directory }}
40+
41+
- name: Load version and package info
2942
uses: baileympearson/drivers-github-tools/node/get_version_info@add-signing-env-action-for-node
3043
with:
3144
npm_package_name: ${{ inputs.npm_package_name }}
3245

3346
- name: Set up drivers-github-tools
3447
uses: mongodb-labs/drivers-github-tools/setup@v2
35-
with:
48+
with:
3649
aws_region_name: ${{ inputs.aws_region_name }}
3750
aws_role_arn: ${{ inputs.aws_role_arn }}
3851
aws_secret_id: ${{ inputs.aws_secret_id }}
3952

53+
- name: Determine what files to sign
54+
if: ${{ inputs.sign_native == 'true' }}
55+
shell: bash
56+
run: |
57+
FILENAMES="build-*/*.tar.gz"
58+
if [[ $FILENAMES =~ '*' ]]; then
59+
FILENAMES=$(ls $FILENAMES | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')
60+
fi
61+
FILENAMES="$FILENAMES ${{ env.package_file }}"
62+
echo "FILES_TO_SIGN=${FILENAMES}" >> "$GITHUB_ENV"
63+
64+
- name: Determine what files to sign
65+
if: ${{ inputs.sign_native != 'true' }}
66+
shell: bash
67+
run: |
68+
FILENAMES="${{ env.package_file }}"
69+
echo "FILES_TO_SIGN=${FILENAMES}" >> "$GITHUB_ENV"
70+
4071
- name: Create detached signature
41-
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
42-
with:
43-
filenames: ${{ env.package_file }}
44-
env:
45-
RELEASE_ASSETS: ${{ env.package_file }}.temp.sig
72+
uses: baileympearson/drivers-github-tools/gpg-sign@add-signing-env-action-for-node
73+
with:
74+
filenames: ${{ env.FILES_TO_SIGN }}
75+
env:
76+
RELEASE_ASSETS: ${{ inputs.artifact_directory }}
77+
78+
- name: Copy the tarballs to the artifacts directory
79+
shell: bash
80+
run: for filename in ${{ env.FILES_TO_SIGN }}; do cp ${filename} artifacts/; done
4681

47-
- name: Name release asset correctly
48-
run: mv ${{ env.package_file }}.temp.sig ${{ env.package_file }}.sig
82+
- name: Display structure of downloaded files
4983
shell: bash
84+
run: ls -la artifacts/
5085

5186
- name: "Upload release artifacts"
5287
if: ${{ inputs.dry_run == false }}
53-
run: gh release upload v${{ env.package_version }} ${{ env.package_file }}.sig
88+
run: gh release upload v${{ env.package_version }} artifacts/*.*
5489
shell: bash
5590
env:
56-
GH_TOKEN: ${{ github.token }}
91+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)