|
| 1 | +name: Bump and Tag |
| 2 | +description: "Bump Version and Create Tag" |
| 3 | +inputs: |
| 4 | + version: |
| 5 | + description: "The next version to set" |
| 6 | + post_version: |
| 7 | + description: "The post version to set" |
| 8 | + app_id: |
| 9 | + description: "The app id of the bot" |
| 10 | + private_key: |
| 11 | + description: "The private key of the bot" |
| 12 | + garasign_username: |
| 13 | + description: "The garasign username" |
| 14 | + garasign_password: |
| 15 | + description: "The garasign password" |
| 16 | + artifactory_username: |
| 17 | + description: "The artifactory username" |
| 18 | + artifactory_password: |
| 19 | + description: "The artifactory password" |
| 20 | + gpg_key_id: |
| 21 | + description: "The gpg key id" |
| 22 | + dry_run: |
| 23 | + description: "Whether this is a dry run" |
| 24 | + |
| 25 | +runs: |
| 26 | + using: composite |
| 27 | + steps: |
| 28 | + - uses: actions/create-github-app-token@v1 |
| 29 | + id: app-token |
| 30 | + with: |
| 31 | + app-id: ${{ inputs.app_id }} |
| 32 | + private-key: ${{ inputs.app_private_key }} |
| 33 | + |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + token: ${{ steps.app-token.outputs.token }} |
| 37 | + |
| 38 | + - uses: actions/setup-python@v4 |
| 39 | + with: |
| 40 | + python-version: '3.11' |
| 41 | + |
| 42 | + - name: Set up Git Config |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + # Use the GitHub Actions bot as the actor. |
| 46 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 47 | + git config user.name "github-actions[bot]" |
| 48 | +
|
| 49 | + - name: Set up new version |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + export CURRENT_VERSION=$(python setup.py --version) |
| 53 | + export NEW_VERSION=${{inputs.version}} |
| 54 | + sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" pyproject.toml |
| 55 | + git add . |
| 56 | +
|
| 57 | + - name: Commit the new version |
| 58 | + uses: mongodb-labs/drivers-github-tools/garasign/git-sign@main |
| 59 | + with: |
| 60 | + command: git commit -a -m "BUMP ${{ inputs.version }}" -s --gpg-sign=${{ inputs.gpg_key_id }} |
| 61 | + garasign_username: ${{ inputs.garasign_username }} |
| 62 | + garasign_password: ${{ inputs.garasign_password }} |
| 63 | + artifactory_username: ${{ inputs.art_user }} |
| 64 | + artifactory_password: ${{ inputs.art_password }} |
| 65 | + |
| 66 | + - name: Tag the new version |
| 67 | + uses: mongodb-labs/drivers-github-tools/garasign/git-sign@main |
| 68 | + with: |
| 69 | + command: git tag -a "${{ inputs.version }}" -m "BUMP ${{ inputs.version }}" -s --local-user=${{ inputs.gpg_key_id }} |
| 70 | + garasign_username: ${{ inputs.garasign_username }} |
| 71 | + garasign_password: ${{ inputs.garasign_password }} |
| 72 | + artifactory_username: ${{ inputs.artifactory_user }} |
| 73 | + artifactory_password: ${{ inputs.artifactory_password }} |
| 74 | + skip_setup: true |
| 75 | + |
| 76 | + - name: Set up the post version |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + export CURRENT_VERSION=${{ inputs.version }} |
| 80 | + export NEW_VERSION=${{ inputs.post_verion }} |
| 81 | + sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" pyproject.toml |
| 82 | + git add . |
| 83 | +
|
| 84 | + - name: Commit the post version |
| 85 | + uses: mongodb-labs/drivers-github-tools/garasign/git-sign@main |
| 86 | + with: |
| 87 | + command: git commit -a -m "BUMP ${{ inputs.post_verion }}" -s --gpg-sign=${{ inputs.gpg_key_id }}" |
| 88 | + garasign_username: ${{ inputs.garasign_username }} |
| 89 | + garasign_password: ${{ inputs.garasign_password }} |
| 90 | + artifactory_username: ${{ inputs.artifactory_user }} |
| 91 | + artifactory_password: ${{ inputs.artifactory_password }} |
| 92 | + skip_setup: true |
| 93 | + |
| 94 | + - name: Verify the tag |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + curl -O https://pgp.mongodb.com/python-driver.pub |
| 98 | + gpg --import python-driver.pub |
| 99 | + git verify-tag ${{inputs.version}} |
| 100 | + rm python-driver.pub |
| 101 | +
|
| 102 | + - name: Push the version and tags to the source branch |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + if [ -n "$(git status --porcelain)" ]; then |
| 106 | + echo "Uncommitted changes!" |
| 107 | + git status --porcelain |
| 108 | + exit 1 |
| 109 | + fi |
| 110 | + if [ ${{ inputs.dry_run }} != "true" ]; then |
| 111 | + git push origin --tags |
| 112 | + git push origin |
| 113 | + fi |
0 commit comments