-
Notifications
You must be signed in to change notification settings - Fork 3
185 lines (159 loc) · 5.63 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#
# Copyright 2022 ABSA Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Release
on:
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
test-python:
strategy:
matrix:
python-version: [ "3.10" ]
runs-on: ubuntu-latest
name: Test Pramen-Py
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: setup poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.4.2
- name: install dependencies
working-directory: "./pramen-py"
run: make --silent install
- name: test
working-directory: "./pramen-py"
env:
ENV: ci
run: make --silent test
release-python:
needs: [ "test-python" ]
runs-on: ubuntu-latest
name: Release Python artifact
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Prepare the release branch
id: release_branch1
working-directory: "./pramen"
run: |
VERSION=$(grep "ThisBuild / version" version.sbt | cut -d\" -f2 | sed 's/-SNAPSHOT//')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
git config --global user.email "[email protected]"
git config --global user.name "CI/CD bot"
git checkout -b release/$VERSION
git push --set-upstream origin release/$VERSION
- name: Update version number
id: release_branch
working-directory: "./pramen-py"
env:
VERSION: ${{ steps.release_branch1.outputs.VERSION }}
run: |
PY_VERSION=$(grep -m 1 ^version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
if [[ "$PY_VERSION" != "$VERSION" ]]; then
sed -i "s/version = \"$PY_VERSION\"/version = \"$VERSION\"/g" pyproject.toml
git add pyproject.toml
git commit -m "Update version number to $VERSION"
git push
fi
- name: install project dependencies
run: |
sudo apt install -y --no-install-recommends \
libssl-dev \
make
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: abatilo/[email protected]
with:
poetry-version: 1.4.2
- name: Install dependencies
working-directory: "./pramen-py"
run: poetry install --no-interaction --no-root
- name: build and publish the wheel to jfrog
working-directory: "./pramen-py"
env:
ENV: pypi
PRAMENPY_PYPI_TOKEN: ${{ secrets.PRAMENPY_PYPI_TOKEN }}
run: make --silent publish
release-sbt:
needs: [ "release-python" ]
runs-on: ubuntu-latest
name: Release Scala artifacts
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Setup JDK and sbt
uses: actions/[email protected]
with:
distribution: temurin
java-version: 8
cache: sbt
- name: Import GPG Key
run: |
echo "${{ secrets.ABSA_OSS_CI_CD_BOT_GPG_KEY }}" > gpg-secret-key.asc
gpg --import --batch gpg-secret-key.asc && rm -rf gpg-secret-key.asc
mkdir -p ~/.gnupg
- name: Setup SonaType config
run: |
mkdir -p ~/.sbt/1.0
echo "${{ secrets.SONATYPE_CONFIG }}" | base64 --decode > ~/.sbt/1.0/sonatype.sbt
- name: Checkout the release branch
working-directory: ./pramen
run: |
VERSION=$(grep "ThisBuild / version" version.sbt | cut -d\" -f2 | sed 's/-SNAPSHOT//')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
git config --global user.email "[email protected]"
git config --global user.name "CI/CD bot"
git fetch origin release/$VERSION
git checkout release/$VERSION
- name: Run the release plugin
working-directory: ./pramen
run: sbt releaseNow
create-pr:
needs: [ "release-sbt" ]
runs-on: ubuntu-latest
name: Create Pull Request
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Checkout the release branch
id: release_branch3
working-directory: ./pramen
run: |
VERSION=$(grep "ThisBuild / version" version.sbt | cut -d\" -f2 | sed 's/-SNAPSHOT//')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
git config --global user.email "[email protected]"
git config --global user.name "CI/CD bot"
git fetch origin release/$VERSION
git checkout release/$VERSION
- name: Create Pull Request
run: gh pr create -B main -H "release/$VERSION" --title "Release Pramen v$VERSION" --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.release_branch3.outputs.VERSION }}