-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (136 loc) · 4.45 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
name: Build, Deploy and Release
on:
push:
branches:
- 'main'
paths:
- 'pyproject.toml'
permissions:
contents: write
jobs:
format-lint:
name: "Format and Lint"
uses: ./.github/workflows/_format-lint-action.yml
with:
python-version: '3.9'
check-coverage:
name: "Check Coverage"
needs: [format-lint]
uses: ./.github/workflows/_check-coverage-action.yml
permissions:
pull-requests: write
with:
required-coverage: ${{ vars.REQUIRED_COVERAGE }}
coverage-module: "geneweaver.api"
test:
name: "Run Tests"
needs: [check-coverage, format-lint]
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11']
uses: ./.github/workflows/_run-tests-action.yml
with:
runner-os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
required-coverage: ${{ vars.REQUIRED_COVERAGE }}
version:
needs: test
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.version_check.outputs.should_release }}
prerelease: ${{ steps.version_check.outputs.prerelease }}
version: ${{ steps.version_check.outputs.version }}
schedule_prod_release: ${{ steps.version_check.outputs.schedule_prod_release }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install toml
- name: Check for version change
id: version_check
run: |
# Extract version from pyproject.toml
version=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
echo "Version=$version"
echo "version=$version" >> $GITHUB_OUTPUT
# Check if this version tag already exists
if git rev-parse "v$version" >/dev/null 2>&1; then
echo "Version already released"
export SHOULD_RELEASE=false
else
echo "New version detected"
export SHOULD_RELEASE=true
fi
if [[ $version =~ [a-zA-Z] ]]; then
echo "Pre-release version detected"
export PRERELEASE=true
else
echo "Full release version detected"
export PRERELEASE=false
fi
if [[ "$SHOULD_RELEASE" == "true" && "$PRERELEASE" == "false" ]]; then
export SCHEDULE_PROD_RELEASE=true
else
export SCHEDULE_PROD_RELEASE=false
fi
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
echo "schedule_prod_release=$SCHEDULE_PROD_RELEASE" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
build:
name: "Build"
needs: [ test, check-coverage, format-lint, version ]
if: ${{ needs.version.outputs.should_release == 'true' }}
uses: ./.github/workflows/_skaffold-build-k8s.yml
secrets: inherit
deploy_sqa:
name: "Deploy: SQA"
needs: [build, version]
if: ${{ needs.version.outputs.should_release == 'true' }}
uses: ./.github/workflows/_skaffold-deploy-k8s.yml
secrets: inherit
with:
environment: "jax-cluster-dev-10--sqa"
deploy_stage:
name: "Deploy: Stage"
needs: [ build, version, deploy_sqa]
if: ${{ needs.version.outputs.schedule_prod_release == 'true' }}
uses: ./.github/workflows/_skaffold-deploy-k8s.yml
secrets: inherit
with:
environment: "jax-cluster-prod-10--stage"
deploy_prod:
name: "Deploy: Prod"
needs: [ build, version, deploy_stage]
if: ${{ needs.version.outputs.schedule_prod_release == 'true' }}
uses: ./.github/workflows/_skaffold-deploy-k8s.yml
secrets: inherit
with:
environment: "jax-cluster-prod-10--prod"
release:
name: "Create Github Release Draft"
runs-on: ubuntu-latest
needs: [ deploy_prod ]
if: ${{ needs.version.outputs.schedule_prod_release == 'true' }}
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version_check.outputs.version }}
name: Release v${{ needs.version.outputs.version }}
draft: true
prerelease: ${{ needs.version.outputs.prerelease }}
body: |
Release v${{ needs.version.outputs.version }}
files: |
dist/*
LICENSE
README.md