forked from projectnessie/nessie
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (104 loc) · 4.59 KB
/
bump-version.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
# Copyright (C) 2020 Dremio
#
# 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.
# Projectnessie Update development version on 'main' (or another branch) to the next
# patch/minor/major version as a -SNAPSHOT version.
# Manually triggered workflow, takes the optional "bumpType" and "bumpBranch" arguments.
# This workflow creates a Git commit to bump the development version.
# Secrets:
# NESSIE_BUILDER GH access-token to push the release-commits+tag to the branch,
# bypassing the required commit-hooks + review.
name: Bump version
on:
# Manually triggered
workflow_dispatch:
inputs:
bumpType:
description: 'Bump what (`patch`, `minor`, `major`), defaults to `patch`'
required: true
type: string
default: "patch"
bumpBranch:
description: 'The branch name to bump the version in, leave empty to bump the version on the `main` branch.'
required: true
type: string
default: "main"
jobs:
create-release:
name: Bump version
runs-on: ubuntu-20.04
env:
BUMP_ON_BRANCH: ${{ github.event.inputs.bumpBranch }}
BUMP_TYPE: ${{ github.event.inputs.bumpType }}
steps:
### BEGIN runner setup
- name: Checkout
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.BUMP_ON_BRANCH }}
- name: Setup Java, Gradle
uses: ./.github/actions/dev-tool-java
- name: Setup Python
uses: ./.github/actions/dev-tool-python
with:
python-version: '3.8'
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install bump2version
# Remove the following, once https://github.com/c4urself/bump2version/issues/30 is fixed
# and the two workarounds below are removed.
python3 -m pip install -r python/requirements.txt
### END runner setup
- name: Get previous version information
run: echo "PREVIOUS_VERSION=$(cat version.txt)" >> ${GITHUB_ENV}
- name: Bump to version
uses: gradle/gradle-build-action@v2
with:
cache-read-only: true
arguments: :bumpVersion --bumpType ${{ env.BUMP_TYPE }}
- name: Get bumped version information
run: |
echo "BUMPED_VERSION=$(cat version.txt)" >> ${GITHUB_ENV}
echo "BUMPED_VERSION_NO_SNAPSHOT=${BUMPED_VERSION%-SNAPSHOT}" >> ${GITHUB_ENV}
- name: Bump versions for Python, site/, helm and UI
uses: ./.github/actions/bump-versions
with:
new-version: ${{ env.BUMPED_VERSION_NO_SNAPSHOT }}
- name: Configure bump-version-bot-user in git config
run: |
git config --global user.email "nessie-bump-version-workflow-noreply@projectnessie.org"
git config --global user.name "Nessie Bump Version Workflow [bot]"
# Record the next development iteration in git
- name: Record next development version in git
run: git commit -a -m "[bump-version] bump to ${BUMPED_VERSION}"
- name: Version information
run: |
cat <<! >> $GITHUB_STEP_SUMMARY
## Version information
| **Previous Nessie version** | ${PREVIOUS_VERSION} |
| **Current Nessie version** | ${BUMPED_VERSION} |
| **Bump type** | ${BUMP_TYPE} |
| Git HEAD | \`$(git rev-parse HEAD)\` |
!
# Push the Git commit. If this one fails, some other commit was pushed to the
# 'main' branch and break the linear history for the Nessie git repo.
- name: Push Git commit
run: |
# Push directly using the remote repo URL, which includes the secret so this job can push to the repo
UPSTREAM="https://${{ secrets.NESSIE_BUILDER }}@github.com/${GITHUB_REPOSITORY}.git"
# Move the default auth settings in ~/.gitconfig out of the way, so the git-push can use the token
git config --rename-section http.https://github.com/ http.https://save.github.com/
git push --no-verify "${UPSTREAM}" HEAD:${GITHUB_REF}
# Move the default auth settings in ~/.gitconfig back
git config --rename-section http.https://save.github.com/ http.https://github.com/