|
| 1 | +name: Release new version of uw-saml-python |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - test-release-workflow |
| 8 | + |
| 9 | +env: |
| 10 | + workflow_url: > |
| 11 | + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 12 | + dry_run: ${{ github.ref != 'refs/heads/main' }} |
| 13 | + SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_BOT_TOKEN }} |
| 14 | + GCLOUD_TOKEN: ${{ secrets.GCR_TOKEN }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-release: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - uses: abatilo/actions-poetry@v2.1.4 |
| 22 | + - with: |
| 23 | + project_id: ${{ secrets.IAM_GCR_REPO }} |
| 24 | + service_account_key: ${{ env.GCLOUD_TOKEN }} |
| 25 | + export_default_credentials: true |
| 26 | + uses: google-github-actions/setup-gcloud@v0.2.1 |
| 27 | + |
| 28 | + - run: | |
| 29 | + echo "::set-output name=version::$(poetry version -s) |
| 30 | + echo "::set-output name=short-sha::${${{ github.sha }}:0:10 |
| 31 | + id: configure |
| 32 | +
|
| 33 | + - uses: UWIT-IAM/actions/set-up-slack-notification-canvas@0.1.8 |
| 34 | + with: |
| 35 | + json: > |
| 36 | + { |
| 37 | + "description": "${{ github.workflow }}", |
| 38 | + "status": "in progress", |
| 39 | + "channel": "#iam-bots", |
| 40 | + "steps": [ |
| 41 | + { |
| 42 | + "description": "Configure <${{ env.workflow_url }} | workflow>", |
| 43 | + "status": "succeeded", |
| 44 | + "stepId": "configure" |
| 45 | + }, |
| 46 | + { |
| 47 | + "description": "Run tests", |
| 48 | + "status": "in progress", |
| 49 | + "stepId": "run-tests" |
| 50 | + }, |
| 51 | + { |
| 52 | + "description": "Release version ${{ steps.configure.outputs.version }}", |
| 53 | + "stepId": "release" |
| 54 | + } |
| 55 | + ] |
| 56 | + } |
| 57 | +
|
| 58 | + - uses: UWIT-IAM/actions/update-slack-workflow-canvas@main |
| 59 | + env: |
| 60 | + commit_url: > |
| 61 | + https://github.com/${{ github.repository }}/commit/${{ github.sha }} |
| 62 | + with: |
| 63 | + command: add-artifact |
| 64 | + description: > |
| 65 | + <${{ env.workflow_url }} | Workflow> triggered by ${{ github.actor }} |
| 66 | + from a ${{ github.event_name }} at |
| 67 | + <${{ env.commit_url }} | commit ${{ steps.configure.outputs.short-sha }}> |
| 68 | +
|
| 69 | + - run: ./scripts/pre-push.sh --check-only |
| 70 | + id: run-tests |
| 71 | + |
| 72 | + - if: always() |
| 73 | + uses: UWIT-IAM/actions/update-slack-workflow-canvas@main |
| 74 | + env: |
| 75 | + test-status: ${{ steps.run-tests.outcome == 'success' && 'succeeded' || 'failed' }} |
| 76 | + release-status: ${{ steps.run-tests.outcome == 'success' && 'in progress' || 'not started' }} |
| 77 | + with: |
| 78 | + command: update-workflow |
| 79 | + step-id: run-tests, release |
| 80 | + step-status: ${{ env.test-status }}, ${{ env.release-status }} |
| 81 | + |
| 82 | + - uses: ncipollo/release-action@v1.8.6 |
| 83 | + if: ${{ ! env.dry_run }} |
| 84 | + id: create-release |
| 85 | + with: |
| 86 | + token: ${{ github.token }} |
| 87 | + commit: ${{ github.sha }} |
| 88 | + tag: ${{ steps.configure.outputs.version }} |
| 89 | + |
| 90 | + - uses: UWIT-IAM/actions/update-slack-workflow-canvas@main |
| 91 | + env: |
| 92 | + release_version: ${{ steps.configure.outputs.version }} |
| 93 | + release_url: ${{ steps.create-release.outputs.html_url || 'https://www.example.com' }} |
| 94 | + action_desc: ${{ env.dry_run == 'true' && 'Dry-run for' || 'Published' }} |
| 95 | + with: |
| 96 | + command: add-artifact |
| 97 | + description: > |
| 98 | + ${{ env.action_desc }} release |
| 99 | + <${{ env.release_url }} | ${{ env.release_version }}> |
| 100 | +
|
| 101 | + - run: | |
| 102 | + poetry publish \ |
| 103 | + --build \ |
| 104 | + $(test "${{ env.dry_run }}" == "false" || echo "--dry-run") |
| 105 | + id: publish-release |
| 106 | +
|
| 107 | + - if: always() |
| 108 | + uses: UWIT-IAM/actions/finalize-slack-notification-canvas@0.1.8 |
| 109 | + with: |
| 110 | + workflow-status: ${{ job.status == 'failure' && 'failed' || 'succeeded' }} |
0 commit comments