Skip to content

Commit 8650a29

Browse files
authored
cicd: add workflow for retrying release (#248)
1 parent bb02d0c commit 8650a29

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/cd_retry.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Retry Continuous Delivery of Python package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
production_release:
7+
description: "Production release?"
8+
type: boolean
9+
required: true
10+
default: true
11+
12+
concurrency: release
13+
14+
permissions:
15+
contents: write
16+
packages: read
17+
18+
jobs:
19+
ci-check-python:
20+
name: Check Python
21+
uses: ./.github/workflows/check-python.yaml
22+
23+
ci-build-python:
24+
name: Build Python
25+
uses: ./.github/workflows/build-python.yaml
26+
needs: ci-check-python
27+
28+
release:
29+
name: Release Library
30+
needs: ci-build-python
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/create-github-app-token@v1
35+
id: app-token
36+
with:
37+
app-id: ${{ secrets.BOT_ID }}
38+
private-key: ${{ secrets.BOT_SK }}
39+
40+
- uses: actions/checkout@v3
41+
with:
42+
# Fetch entire repository history so we can determine version number from it
43+
fetch-depth: 0
44+
# use release token for production_release, standard token otherwise
45+
token: ${{ steps.app-token.outputs.token }}
46+
47+
- name: Install poetry
48+
run: pipx install poetry
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v4
52+
with:
53+
python-version: "3.10"
54+
cache: "poetry"
55+
56+
- name: Install dependencies
57+
run: poetry install --no-interaction --no-root
58+
59+
- name: Get branch name
60+
shell: bash
61+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
62+
id: get_branch
63+
64+
- name: Set Git user as GitHub actions
65+
run: git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
66+
67+
- name: Create Continuous Deployment - Beta (non-prod)
68+
if: "${{ steps.get_branch.outputs.branch == 'master' && !inputs.production_release && !contains(github.event.head_commit.message, 'skip-checks: true') }}"
69+
run: |
70+
poetry run semantic-release \
71+
-v DEBUG \
72+
--prerelease \
73+
--define=upload_to_repository=true \
74+
--define=branch=master \
75+
--retry \
76+
publish
77+
gh release edit --prerelease "$(poetry run semantic-release print-version --current)"
78+
env:
79+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
80+
REPOSITORY_USERNAME: __token__
81+
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_KEY }}
82+
83+
- name: Create Continuous Deployment - Production
84+
if: steps.get_branch.outputs.branch == 'master' && inputs.production_release
85+
run: |
86+
poetry run semantic-release \
87+
-v DEBUG \
88+
--define=version_source="commit" \
89+
--define=branch=master \
90+
--define=upload_to_repository=true \
91+
--define=patch_without_tag=true \
92+
--retry \
93+
publish
94+
env:
95+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
96+
REPOSITORY_USERNAME: __token__
97+
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_KEY }}

0 commit comments

Comments
 (0)