-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (128 loc) · 4.21 KB
/
bump-build-publish-cli.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
name: Bump version, Build, and Publish the CLI to PyPI
on:
push:
branches:
- main
paths-ignore:
- '*.md'
- '.github/**'
workflow_dispatch:
inputs:
bump:
description: 'Part of the version to bump: major, minor, patch'
required: false
default: 'patch'
type: choice
options:
- patch
- minor
- major
branch:
description: 'Branch to run the workflow on'
required: false
default: 'main'
jobs:
bump-check:
runs-on: ubuntu-latest
outputs:
is-bump: ${{ steps.skiptest.outputs.is-bump }}
steps:
- uses: actions/checkout@v2
- name: Skip version bump merges
id: skiptest
uses: ./.github/actions/bump-skip
with:
event-name: ${{ github.event_name }}
tag-job:
needs: [ bump-check ]
runs-on: ubuntu-latest
if: needs.bump-check.outputs.is-bump == 'no'
outputs:
tag: ${{ steps.tag.outputs.new_tag }}
steps:
- name: Set part of semantic version to bump
id: controls
run: |
SEMVER_PART=""
CHECKOUT_BRANCH="$GITHUB_REF"
if ${{github.event_name == 'push' }}; then
SEMVER_PART="patch"
elif ${{github.event_name == 'workflow_dispatch' }}; then
SEMVER_PART=${{ github.event.inputs.bump }}
CHECKOUT_BRANCH=${{ github.event.inputs.branch }}
fi
echo ::set-output name=semver-part::$SEMVER_PART
echo ::set-output name=checkout-branch::$CHECKOUT_BRANCH
- name: Checkout current code
uses: actions/checkout@v2
with:
ref: ${{ steps.controls.outputs.checkout-branch }}
token: ${{ secrets.BROADBOT_TOKEN }}
- name: Bump the tag to a new version
# https://github.com/DataBiosphere/github-actions/tree/master/actions/bumper
uses: databiosphere/github-actions/actions/bumper@bumper-0.4.0
id: tag
env:
DEFAULT_BUMP: patch
GITHUB_TOKEN: ${{ secrets.BROADBOT_TOKEN }}
HOTFIX_BRANCHES: hotfix.*
OVERRIDE_BUMP: ${{ steps.controls.outputs.semver-part }}
RELEASE_BRANCHES: main
VERSION_FILE_PATH: pyproject.toml
VERSION_LINE_MATCH: "^version\\s*=\\s*\".*\""
build-and-publish:
name: Build and publish Python client to PyPI
needs: [ bump-check, tag-job ]
if: needs.bump-check.outputs.is-bump == 'no'
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing (OIDC)
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.tag-job.outputs.tag }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Report current terralab-cli version
run: |
poetry version
- name: Build the CLI using poetry
run: |
poetry build
- name: Publish the CLI to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
notify-slack:
needs: [ bump-check, tag-job, build-and-publish ]
runs-on: ubuntu-latest
if: failure() && needs.bump-check.outputs.is-bump == 'no'
steps:
- name: Notify Teaspoons Slack on Failure
uses: broadinstitute/action-slack@v3.8.0
# see https://github.com/broadinstitute/action-slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: failure
channel: "#terra-tsps-alerts"
username: "Bump, Build, and Publish Terralab CLI"
author_name: "bump-build-publish-cli workflow"
icon_emoji: ":triangular_ruler:"
fields: job, commit
# Run e2e tests
run-cli-e2e-tests:
name: Run e2e tests on newly published Python client
needs: [ tag-job ]
uses: ./.github/workflows/run-e2e-tests.yml
secrets:
BROADBOT_TOKEN: ${{ secrets.BROADBOT_TOKEN }}
with:
cli-version-ref: ${{ needs.tag-job.outputs.checkout-ref }}