|
| 1 | +name: Publish Ruby |
| 2 | +description: Generate and publish gems, signatures, and assets for MongoDB Ruby projects |
| 3 | +inputs: |
| 4 | + app_id: |
| 5 | + description: The APP_ID defined for this project |
| 6 | + required: true |
| 7 | + app_private_key: |
| 8 | + description: The APP_PRIVATE_KEY defined for this project |
| 9 | + required: true |
| 10 | + aws_role_arn: |
| 11 | + description: The AWS_ROLE_ARN defined for this project |
| 12 | + required: true |
| 13 | + aws_region_name: |
| 14 | + description: The AWS_REGION_NAME defined for this project |
| 15 | + required: true |
| 16 | + aws_secret_id: |
| 17 | + description: The AWS_SECRET_ID defined for this project |
| 18 | + required: true |
| 19 | + dry_run: |
| 20 | + description: Whether this is a dry run or not ("false" for releases) |
| 21 | + required: true |
| 22 | + gem_name: |
| 23 | + description: The name (sans extension) of the gemspec file (e.g. "mongo") |
| 24 | + required: true |
| 25 | + product_name: |
| 26 | + description: The name of the product being published (e.g. "Ruby Driver") |
| 27 | + required: true |
| 28 | + product_id: |
| 29 | + description: The identifier of the product being published (e.g. "mongo-ruby-driver") |
| 30 | + required: true |
| 31 | + release_message_template: |
| 32 | + description: The template for the release message. Use "{0}" in the text to refer to the current version. |
| 33 | + required: true |
| 34 | + silk_asset_group: |
| 35 | + description: The Silk asset group for the project |
| 36 | + required: true |
| 37 | + |
| 38 | +runs: |
| 39 | + using: composite |
| 40 | + steps: |
| 41 | + - name: Check out the repository |
| 42 | + uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 |
| 43 | + with: |
| 44 | + app_id: ${{ inputs.app_id }} |
| 45 | + private_key: ${{ inputs.app_private_key }} |
| 46 | + |
| 47 | + - name: Setup Ruby |
| 48 | + uses: ruby/setup-ruby@v1 |
| 49 | + with: |
| 50 | + ruby-version: '3.2' |
| 51 | + bundler-cache: true |
| 52 | + |
| 53 | + - name: Get the release version |
| 54 | + shell: bash |
| 55 | + run: echo "RELEASE_VERSION=$(bundle exec rake version)" >> "$GITHUB_ENV" |
| 56 | + |
| 57 | + - name: Setup GitHub tooling for DBX Drivers |
| 58 | + uses: mongodb-labs/drivers-github-tools/setup@v2 |
| 59 | + with: |
| 60 | + aws_role_arn: ${{ inputs.aws_role_arn }} |
| 61 | + aws_region_name: ${{ inputs.aws_region_name }} |
| 62 | + aws_secret_id: ${{ inputs.aws_secret_id }} |
| 63 | + |
| 64 | + - name: Set output gem file name |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + echo "GEM_FILE_NAME=${{ inputs.gem_name }}-${{ env.RELEASE_VERSION }}.gem" >> "$GITHUB_ENV" |
| 68 | +
|
| 69 | + - name: Build the gem |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + gem build --output=${{ env.GEM_FILE_NAME }} ${{ inputs.gem_name }}.gemspec |
| 73 | +
|
| 74 | + - name: Sign the gem |
| 75 | + uses: mongodb-labs/drivers-github-tools/gpg-sign@v2 |
| 76 | + with: |
| 77 | + filenames: '${{ env.GEM_FILE_NAME }}' |
| 78 | + |
| 79 | + - name: Generate SSDLC Reports |
| 80 | + uses: mongodb-labs/drivers-github-tools/full-report@v2 |
| 81 | + with: |
| 82 | + product_name: ${{ inputs.product_name }} |
| 83 | + release_version: ${{ env.RELEASE_VERSION }} |
| 84 | + dist_filenames: ${{ env.GEM_FILE_NAME }} |
| 85 | + silk_asset_group: ${{ inputs.silk_asset_group }} |
| 86 | + |
| 87 | + - name: Create the tag |
| 88 | + uses: mongodb-labs/drivers-github-tools/tag-version@v2 |
| 89 | + with: |
| 90 | + version: ${{ env.RELEASE_VERSION }} |
| 91 | + tag_template: "v${VERSION}" |
| 92 | + tag_message_template: "Release tag for v${VERSION}" |
| 93 | + |
| 94 | + - name: Create a new release |
| 95 | + shell: bash |
| 96 | + run: gh release create v${{ env.RELEASE_VERSION }} --title ${{ env.RELEASE_VERSION }} --generate-notes --draft |
| 97 | + |
| 98 | + - name: Capture the changelog |
| 99 | + shell: bash |
| 100 | + run: gh release view v${{ env.RELEASE_VERSION }} --json body --template '{{ .body }}' >> changelog |
| 101 | + |
| 102 | + - name: Prepare release message |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + echo "${{ format(inputs.release_message_template, env.RELEASE_VERSION) }}" > release-message |
| 106 | + cat changelog >> release-message |
| 107 | +
|
| 108 | + - name: Update release information |
| 109 | + shell: bash |
| 110 | + run: | |
| 111 | + echo "RELEASE_URL=$(gh release edit v${{ env.RELEASE_VERSION }} --notes-file release-message)" >> "$GITHUB_ENV" |
| 112 | +
|
| 113 | + - name: Upload release artifacts |
| 114 | + shell: bash |
| 115 | + run: gh release upload v${{ env.RELEASE_VERSION }} ${{ env.GEM_FILE_NAME }} ${{ env.RELEASE_ASSETS }}/${{ env.GEM_FILE_NAME }}.sig |
| 116 | + |
| 117 | + - name: Upload S3 assets |
| 118 | + uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2 |
| 119 | + with: |
| 120 | + version: ${{ env.RELEASE_VERSION }} |
| 121 | + product_name: ${{ inputs.product_id }} |
| 122 | + dry_run: ${{ inputs.dry_run }} |
| 123 | + |
| 124 | + - name: Publish the gem |
| 125 | + uses: rubygems/release-gem@v1 |
| 126 | + if: inputs.dry_run == 'false' |
| 127 | + with: |
| 128 | + await-release: false |
0 commit comments