From e76d14300a429c3f55a9b066e71366f68c5b27ed Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 24 Jun 2024 13:36:48 -0600 Subject: [PATCH] use shared actions --- .../compress_sign_and_upload/action.yml | 59 ------------------- .github/workflows/release-5.x.yml | 23 ++++---- .github/workflows/release.yml | 23 ++++---- 3 files changed, 20 insertions(+), 85 deletions(-) delete mode 100644 .github/actions/compress_sign_and_upload/action.yml diff --git a/.github/actions/compress_sign_and_upload/action.yml b/.github/actions/compress_sign_and_upload/action.yml deleted file mode 100644 index 8bce52aa..00000000 --- a/.github/actions/compress_sign_and_upload/action.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Compress and Sign -description: 'Compresses package and signs with garasign' - -inputs: - aws_role_arn: - description: 'AWS role input for drivers-github-tools/gpg-sign@v2' - required: true - aws_region_name: - description: 'AWS region name input for drivers-github-tools/gpg-sign@v2' - required: true - aws_secret_id: - description: 'AWS secret id input for drivers-github-tools/gpg-sign@v2' - required: true - npm_package_name: - description: 'The name for the npm package this repository represents' - required: true - dry_run: - description: 'Should we upload files to the release?' - required: false - default: 'true' - -runs: - using: composite - steps: - - run: npm pack - shell: bash - - - name: Get release version and release package file name - id: get_vars - shell: bash - run: | - package_version=$(jq --raw-output '.version' package.json) - echo "package_version=${package_version}" >> "$GITHUB_OUTPUT" - echo "package_file=${{ inputs.npm_package_name }}-${package_version}.tgz" >> "$GITHUB_OUTPUT" - - - name: Set up drivers-github-tools - uses: mongodb-labs/drivers-github-tools/setup@v2 - with: - aws_region_name: ${{ inputs.aws_region_name }} - aws_role_arn: ${{ inputs.aws_role_arn }} - aws_secret_id: ${{ inputs.aws_secret_id }} - - - name: Create detached signature - uses: mongodb-labs/drivers-github-tools/gpg-sign@v2 - with: - filenames: ${{ steps.get_vars.outputs.package_file }} - env: - RELEASE_ASSETS: ${{ steps.get_vars.outputs.package_file }}.temp.sig - - - name: Name release asset correctly - run: mv ${{ steps.get_vars.outputs.package_file }}.temp.sig ${{ steps.get_vars.outputs.package_file }}.sig - shell: bash - - - name: "Upload release artifacts" - if: ${{ inputs.dry_run == false }} - run: gh release upload v${{ steps.get_vars.outputs.package_version }} ${{ steps.get_vars.outputs.package_file }}.sig - shell: bash - env: - GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release-5.x.yml b/.github/workflows/release-5.x.yml index ed2b5969..ebff278d 100644 --- a/.github/workflows/release-5.x.yml +++ b/.github/workflows/release-5.x.yml @@ -32,23 +32,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: actions/setup uses: ./.github/actions/setup - - name: Get release version and release package file name - id: get_version - shell: bash - run: | - package_version=$(jq --raw-output '.version' package.json) - echo "package_version=${package_version}" >> "$GITHUB_OUTPUT" - echo "package_file=bson-${package_version}.tgz" >> "$GITHUB_OUTPUT" + + - name: Load version and package info + uses: baileympearson/drivers-github-tools/node/get_version_info@add-signing-env-action-for-node - name: actions/compress_sign_and_upload - uses: ./.github/actions/compress_sign_and_upload + uses: baileympearson/drivers-github-tools/node/sign_js_only_package@add-signing-env-action-for-node with: aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} - aws_region_name: 'us-east-1' + aws_region_name: us-east-1 aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - npm_package_name: 'bson' + npm_package_name: bson dry_run: ${{ needs.release_please.outputs.release_created == '' }} - name: Copy sbom file to release assets @@ -58,17 +55,17 @@ jobs: - name: Generate authorized pub report uses: mongodb-labs/drivers-github-tools/full-report@v2 with: - release_version: ${{ steps.get_version.outputs.package_version }} + release_version: ${{ env.package_version.package_version }} product_name: bson sarif_report_target_ref: 5.x third_party_dependency_tool: n/a # and .sig - dist_filenames: ${{ steps.get_version.outputs.package_file }}* + dist_filenames: ${{ env.package_version.package_file }}* token: ${{ github.token }} sbom_file_name: sbom.json - uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2 with: - version: ${{ steps.get_version.outputs.package_version }} + version: ${{ env.package_version.package_version }} product_name: bson dry_run: ${{ needs.release_please.outputs.release_created == '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 715dd729..8ba238d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,23 +30,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: actions/setup uses: ./.github/actions/setup - - name: Get release version and release package file name - id: get_version - shell: bash - run: | - package_version=$(jq --raw-output '.version' package.json) - echo "package_version=${package_version}" >> "$GITHUB_OUTPUT" - echo "package_file=bson-${package_version}.tgz" >> "$GITHUB_OUTPUT" + + - name: Load version and package info + uses: baileympearson/drivers-github-tools/node/get_version_info@add-signing-env-action-for-node - name: actions/compress_sign_and_upload - uses: ./.github/actions/compress_sign_and_upload + uses: baileympearson/drivers-github-tools/node/sign_js_only_package@add-signing-env-action-for-node with: aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} - aws_region_name: 'us-east-1' + aws_region_name: us-east-1 aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - npm_package_name: 'bson' + npm_package_name: bson dry_run: ${{ needs.release_please.outputs.release_created == '' }} - name: Copy sbom file to release assets @@ -56,18 +53,18 @@ jobs: - name: Generate authorized pub report uses: mongodb-labs/drivers-github-tools/full-report@v2 with: - release_version: ${{ steps.get_version.outputs.package_version }} + release_version: ${{ env.package_version }} product_name: bson sarif_report_target_ref: main third_party_dependency_tool: n/a # and .sig - dist_filenames: ${{ steps.get_version.outputs.package_file }}* + dist_filenames: ${{ env.package_version.package_file }}* token: ${{ github.token }} sbom_file_name: sbom.json - uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2 with: - version: ${{ steps.get_version.outputs.package_version }} + version: ${{ env.package_version.package_version }} product_name: bson dry_run: ${{ needs.release_please.outputs.release_created == '' }}