Skip to content

Commit 47bb1af

Browse files
author
Thomas Thorogood
authored
[IAM-276] Migrate release workflow to Github Actions (#21)
- Auto-bump version based on pull request vendor guidance - Add release workflow which is triggered on pushes to `main`. (Dry runs are triggered from pushes to `test-release-workflow`.)
1 parent 924173f commit 47bb1af

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Change Description:** {{ FILL THIS IN }}
2+
3+
**Closes Jira(s)**: {{ FILL THIS IN }}
4+
5+
## uw-saml-python Pull Request checklist
6+
7+
- [ ] I have run `./scripts/pre-push.sh`
8+
- [ ] I have selected a `semver-guidance:` label for this pull request (under labels,
9+
to the right of the screen)
10+
11+
If you do not do both of these things, your checks will either not run, or have a high probability of failing.

.github/workflows/create-release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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' }}

.github/workflows/pull-request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ jobs:
1313
with:
1414
github-token: ${{ github.token }}
1515
id: guidance
16+
- uses: uwit-iam/actions/update-pr-branch-version@0.1.8
17+
with:
18+
github-token: ${{ github.token }}
19+
version-guidance: ${{ steps.guidance.output.guidance }}
1620
- run: ./scripts/pre-push.sh --check-only

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ venv
55
__pycache__
66
dist
77
.coverage
8+
*.pyc

0 commit comments

Comments
 (0)