-
Notifications
You must be signed in to change notification settings - Fork 28
107 lines (92 loc) · 3.34 KB
/
main.yml
File metadata and controls
107 lines (92 loc) · 3.34 KB
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
name: Main
on:
push:
branches: ["*"] # Run only when push to branches (not tags).
paths-ignore:
- "**/*.md"
- ".vscode/**"
- ".*"
pull_request:
issues:
issue_comment:
workflow_dispatch:
jobs:
issue:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/issues.yaml@main
secrets: inherit
contributor:
uses: ocadotechnology/codeforlife-contributor-backend/.github/workflows/check-pr-authors-signed-latest-agreement.yaml@main
test:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-python-code.yaml@main
secrets: inherit
with:
python-version: 3.12
# TODO: https://python-semantic-release.readthedocs.io/en/latest/automatic-releases/github-actions.html#common-workflow-example
release:
concurrency: release
runs-on: ubuntu-latest
needs: [test]
permissions:
id-token: write
# Release if:
# - the repo's owner is Ocado Tech.
# - a change is made to the default branch.
if: |
github.repository_owner_id == 2088731 &&
github.ref_name == github.event.repository.default_branch
env:
CONFIG: releaserc.toml
steps:
- name: 🤖 Set up CFL bot
uses: ocadotechnology/codeforlife-workspace/.github/actions/bot/setup@main
id: setup-bot
with:
cfl-app-private-key: ${{ secrets.CFL_APP_PRIVATE_KEY }}
- name: 🛫 Checkout
uses: actions/checkout@v5
with:
token: ${{ steps.setup-bot.outputs.token }}
fetch-depth: 0
ref: ${{ github.sha }}
persist-credentials: false
- name: 🛫 Checkout Branch on Workflow SHA
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: 🐍 Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: 🛠 Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build python-semantic-release==9.*
- name: 📜 Detect Semantic Version
env:
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
GIT_COMMIT_AUTHOR: ${{ steps.setup-bot.outputs.git-committer }}
run: |
PYTHON_SCRIPT="from codeforlife import __version__; print(__version__)"
echo OLD_VERSION=$(python -c "$PYTHON_SCRIPT") >> $GITHUB_ENV
semantic-release --config=${{ env.CONFIG }} version
echo NEW_VERSION=$(python -c "$PYTHON_SCRIPT") >> $GITHUB_ENV
- name: 🏗️ Build Distributions
if: env.OLD_VERSION != env.NEW_VERSION
run: python -m build --sdist --wheel
- name: 🚀 Publish to GitHub
if: env.OLD_VERSION != env.NEW_VERSION
env:
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
GIT_COMMIT_AUTHOR: ${{ steps.setup-bot.outputs.git-committer }}
run: semantic-release --config=${{ env.CONFIG }} publish
- name: 🚀 Publish to PyPI
if: env.OLD_VERSION != env.NEW_VERSION
uses: pypa/gh-action-pypi-publish@release/v1
monitor:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/monitor-python-release.yaml@main
secrets: inherit
needs: [release]
with:
python-version: 3.12
submodule:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/gitmodules.yaml@main
secrets: inherit
needs: [release]