-
Notifications
You must be signed in to change notification settings - Fork 75
198 lines (175 loc) · 7.84 KB
/
prepare-rc.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
186
187
188
189
190
191
192
193
194
195
196
197
198
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
#
# This action will produce a zip-archive with all the stuff required for signing and
# deploying an extension release candidate maven artifacts, extension sources and
# binary zip-archive (if applicable). It will also create a rc-tag pointed to the last
# commit in the release branch.
#
name: "Extension Prepare Release Candidate"
on: workflow_dispatch
env:
SERVER_URL: 'https://dist.apache.org/repos/dist/dev/ignite/ignite-extensions/'
jobs:
prepare:
if: github.repository == 'apache/ignite-extensions'
runs-on: ubuntu-latest
name: Prepare RC for `${{ github.ref_name }}`
steps:
- name: Validate Extension Release Branch
id: check
run: |
prefix='false'
[[ ${{ github.ref_name }} =~ ^release/ ]] && prefix='true'
echo "::set-output name=isReleaseBranch::${prefix}"
- name: Interrupt If not a Release Branch
if: ${{ steps.check.outputs.isReleaseBranch == 'false' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed("You should run this action from the release branch which has the 'release/' prefix: ${{ github.ref_name }} ")
- name: Setup Inputs
shell: bash
# see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
run: |
branch=${{ github.ref_name }}
ext=${branch#"release/"}
ext_ver=${ext##*-}
ext_name=${ext%-*}
ext_dir=modules/${ext_name#"ignite-"}
echo "Extension Version: $ext_ver"
echo "Extension Module Name: $ext_name"
echo "Extension Directory: $ext_dir"
echo "EXTENSION_VERSION=${ext_ver}" >> $GITHUB_ENV
echo "EXTENSION_NAME=${ext_name}" >> $GITHUB_ENV
echo "EXTENSION_DIR=${ext_dir}" >> $GITHUB_ENV
echo "EXTENSION_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Checkout Release Branch
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Fetch Release Tags
run: |
git fetch --prune --unshallow --tags
echo $(git tag -l)
echo "GIT_HOME=$(pwd)" >> $GITHUB_ENV
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'adopt'
- name: Extract POM Version and Compare With Branch Version
id: pom
shell: bash
run: |
mvn -pl ${{ env.EXTENSION_DIR }} help:evaluate -Dexpression=project.artifactId
ver=$(mvn -pl ${{ env.EXTENSION_DIR }} help:evaluate -Dexpression=project.version -q -DforceStdout)
pom_ver=$(echo ${ver} | sed -e 's/^[[:space:]]*//')
missmatch='true'
[ "$pom_ver" == "${{ env.EXTENSION_VERSION }}" ] && missmatch='false'
echo "Extension pom version: ${pom_ver}"
echo "::set-output name=versionMissmatch::${missmatch}"
echo "VERSION_POM=${pom_ver}" >> $GITHUB_ENV
- name: Compare Release Versions With Branch Version
if: ${{ steps.pom.outputs.versionMissmatch == 'true' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Versions missmatch [branch=${{ env.EXTENSION_VERSION }}, pom=${{ env.VERSION_POM }}]')
# Get the RC tag reachable from the branch HEAD matching pattern.
- name: Extracting Release RC tag
shell: bash
run: |
tag_prefix=${{ env.EXTENSION_NAME }}-${{ env.EXTENSION_VERSION }}-rc
git describe --match "${tag_prefix}*" --abbrev=0 --tags HEAD || true
branch_tag=$(git describe --match "${tag_prefix}*" --abbrev=0 --tags HEAD || true)
rc_tag=$(echo ${branch_tag:-${tag_prefix}0})
rc_tag_id=$((${rc_tag#"${tag_prefix}"} + 1))
new_tag=${tag_prefix}${rc_tag_id}
echo "New Extension RC tag: ${new_tag}"
echo "EXTENSION_RC_TAG=${new_tag}" >> $GITHUB_ENV
- name: Prepare Release Properties
run: |
dist=${{ env.GIT_HOME }}/target/${{ env.EXTENSION_RC_TAG }}
mkdir -p ${dist} && cd "$_"
touch release.properties
echo EXTENSION_NAME=${{ env.EXTENSION_NAME}} >> release.properties
echo EXTENSION_VERSION=${{ env.EXTENSION_VERSION}} >> release.properties
echo EXTENSION_RC_TAG=${{ env.EXTENSION_RC_TAG}} >> release.properties
echo EXTENSION_DIR=${{ env.EXTENSION_DIR}} >> release.properties
echo EXTENSION_BRANCH=${{ env.EXTENSION_BRANCH}} >> release.properties
echo revision=$(git rev-list --max-count=1 HEAD 2>/dev/null || true) >> release.properties
cat release.properties
echo "EXTENSION_DIST=${dist}" >> $GITHUB_ENV
# The mvn must be started from the module root directory to collect assembly sources.
- name: Build Java and Prepare Packages
run: |
cd ${{ env.GIT_HOME }}/${{ env.EXTENSION_DIR }}
mvn deploy -am -DskipTests -Pextension-release -DuniqueVersion=false ${toLocalRepo}
cd -
env:
toLocalRepo: '-D altDeploymentRepository=local::default::file:${{ env.EXTENSION_DIST }}/maven'
- name: Check there is no SNAPSHOT versions
run: mvn -f ${{ env.EXTENSION_DIR }} -am org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseVersion,requireReleaseDeps
- name: Copy Binary and Sources
run: |
svn_dir=${{ env.EXTENSION_DIST }}/svn/vote
mkdir -p ${svn_dir}
cd ${{ env.GIT_HOME }}/${{ env.EXTENSION_DIR }}
list=$(find . -regex '.*\.zip' -o -regex '.*\.zip\.sha512')
for file in $list; do cp -v ${file} ${svn_dir}; done
cd -
- name: Copy Release Scripts
run: |
cd ${{ env.GIT_HOME }}
cp -v ./scripts/vote* ${{ env.EXTENSION_DIST }}
cp -v ./scripts/settings.xml ${{ env.EXTENSION_DIST }}
chmod +x ${{ env.EXTENSION_DIST }}/*.sh
- name: Create RC tag `${{ env.EXTENSION_RC_TAG }}`
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.EXTENSION_RC_TAG }}',
sha: context.sha
})
- name: Checkout Sources Into Distribution
uses: actions/checkout@v3
with:
path: ${{ env.EXTENSION_DIST }}/git
ref: ${{ github.ref_name }}
- name: Configure Git for Release
run: |
cd ${{ env.EXTENSION_DIST }}/git
git config user.name github-actions
git config user.email [email protected]
git fetch --prune --unshallow --tags
- name: Zip the Distribution
run: |
sudo apt-get -y install zip
cd ${{ env.EXTENSION_DIST }}/..
zip -r ${{ env.EXTENSION_RC_TAG }}.zip ${{ env.EXTENSION_RC_TAG }}/
cd -
- name: Upload Job Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.EXTENSION_RC_TAG }}
path: ${{ env.GIT_HOME }}/target/${{ env.EXTENSION_RC_TAG }}.zip