-
Notifications
You must be signed in to change notification settings - Fork 3
166 lines (148 loc) · 5.76 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release new version of webdriver-recorder
on:
push:
branches:
- master
- test-release-workflow
workflow_dispatch:
inputs:
patch-level:
default: prerelease
required: true
description: "VERSION INSTRUCTION. (Can be an explicit version or a hint
to poetry from patch|minor|major|prerelease)"
dry-run:
required: true
default: 'true'
description: >
DRY RUN? (Change this to 'false' if you are sure you want to release!)
env:
workflow_url: >
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
dry_run: 'true'
SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_BOT_TOKEN }}
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- run: |
if [[ -n "${{ github.event.inputs.dry-run }}" ]]
then
echo 'dry_run=${{ github.event.inputs.dry-run }}' >> $GITHUB_ENV
elif [[ "$(basename ${{ github.ref }})" == "master" ]]
then
echo 'dry_run=false' >> $GITHUB_ENV
fi
- uses: actions/checkout@v2
- with:
project_id: ${{ secrets.IAM_GCR_REPO }}
service_account_key: ${{ secrets.GCR_TOKEN }}
export_default_credentials: true
uses: google-github-actions/[email protected]
- uses: abatilo/[email protected]
- uses: nanasess/setup-chromedriver@v1
- run: |
poetry version ${{ github.event.inputs.patch-level || 'prerelease' }}
set -x
VERSION=$(poetry version -s)
echo "::set-output name=release-version::$VERSION"
echo "::set-output name=short-sha::${GITHUB_SHA:0:10}"
poetry install --no-interaction
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
id: configure
- uses: UWIT-IAM/actions/[email protected]
id: slack
env:
version: ${{ steps.configure.outputs.release-version }}
with:
json: >
{
"description": "${{ github.workflow }}: ${{ env.version }}",
"status": "in progress",
"channel": "#iam-bots",
"steps": [
{
"description": "Configure <${{ env.workflow_url }} | workflow>",
"status": "succeeded",
"stepId": "configure"
},
{
"description": "Run tests",
"status": "in progress",
"stepId": "run-tests"
},
{
"description": "Release version ${{ steps.configure.outputs.release-version }}",
"stepId": "release"
}
]
}
- uses: UWIT-IAM/actions/[email protected]
env:
commit_url: >
https://github.com/${{ github.repository }}/commit/${{ github.sha }}
with:
command: add-artifact
description: >
<${{ env.workflow_url }} | Workflow> triggered by ${{ github.actor }}
from a ${{ github.event_name }} at
<${{ env.commit_url }} | commit ${{ steps.configure.outputs.short-sha }}>
- run: ./validate-strict.sh
id: run-tests
- if: always() && steps.slack.outputs.canvas-id
uses: UWIT-IAM/actions/[email protected]
env:
test-status: ${{ steps.run-tests.outcome == 'success' && 'succeeded' || 'failed' }}
release-status: ${{ steps.run-tests.outcome == 'success' && 'in progress' || 'not started' }}
with:
command: update-workflow
step-id: run-tests, release
step-status: ${{ env.test-status }}, ${{ env.release-status }}
- uses: EndBug/[email protected]
id: update-project-version
env:
commit-message: >
Update pyproject.toml version to
${{ steps.configure.outputs.release-version }}
with:
add: pyproject.toml poetry.lock
pull_strategy: NO-PULL
push: ${{ env.dry_run == 'true' && 'false' || 'true' }}
default_author: github_actor
message: ${{ env.commit-message }}
- id: version-commit
run: echo "::set-output name=sha::$(git rev-parse HEAD)"
shell: bash
- uses: ncipollo/[email protected]
if: env.dry_run != 'true'
id: create-release
with:
token: ${{ github.token }}
commit: ${{ steps.version-commit.outputs.sha }}
tag: ${{ steps.configure.outputs.release-version }}
- uses: UWIT-IAM/actions/[email protected]
env:
release_version: ${{ steps.configure.outputs.release-version }}
release_url: ${{ steps.create-release.outputs.html_url || 'https://www.example.com' }}
action_desc: ${{ env.dry_run == 'true' && 'Dry-run for' || 'Published' }}
with:
command: add-artifact
description: >
${{ env.action_desc }} release
<${{ env.release_url }} | ${{ env.release_version }}>
- run: poetry publish --build
if: env.dry_run != 'true'
id: publish-release
- if: always() && steps.slack.outputs.canvas-id
env:
status: ${{ job.status != 'failure' && 'succeeded' || 'failed' }}
with:
command: update-workflow
step-id: release
step-status: ${{ env.status }}
workflow-status: ${{ env.status }}
uses: UWIT-IAM/actions/[email protected]
- if: always() && steps.slack.outputs.canvas-id
uses: UWIT-IAM/actions/[email protected]
with:
workflow-status: ${{ job.status == 'success' && 'succeeded' || 'failed' }}