-
Notifications
You must be signed in to change notification settings - Fork 11
132 lines (111 loc) · 4.54 KB
/
CreateVersion.yml
File metadata and controls
132 lines (111 loc) · 4.54 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Create Version
on:
workflow_dispatch:
inputs:
version:
description: 'Version to Create'
required: false
jobs:
create_version:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
JEOMETRY_REPO: 'jeometry-org/jeometry'
REVOLSYS_REPO: 'revolsys/com.revolsys.open'
steps:
- name: Init Branch
shell: bash
run: |
BRANCH=${GITHUB_REF#refs/heads/}
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
#### JAVA VERSION ####
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'microsoft'
#### Initialize Environment ####
- name: Initialize Environment
if: ${{env.BRANCH == 'main'}}
run: |
echo "JEOMETRY_REPO=jeometry-org/jeometry" >> $GITHUB_ENV
echo "REVOLSYS_REPO=revolsys/com.revolsys.open" >> $GITHUB_ENV
#### Checkout jeometry ####
- name: Checkout jeometry
uses: actions/checkout@v3
with:
ref: ${{env.BRANCH}}
repository: ${{env.JEOMETRY_REPO}}
path: jeometry
fetch-depth: 0
token: ${{secrets.PUSH_TOKEN}}
#### Checkout revolsys ####
- name: Checkout revolsys
uses: actions/checkout@v3
with:
ref: ${{env.BRANCH}}
repository: ${{github.repository}}
path: revolsys
#### Create Version ####
- name: Git Init
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Git Push Branches
run: |
git -C ./jeometry push -f "https://${USERNAME}:${REPO_KEY}@github.com/jeometry-org/jeometry.git" "$BRANCH"
git -C ./revolsys push -f "https://${USERNAME}:${REPO_KEY}@github.com/revolsys/com.revolsys.open.git" "$BRANCH"
- name: Set Version
run: |
VERSION="${{github.event.inputs.version}}"
if [ "${VERSION}" == "" ]; then
VERSION=${BRANCH#patches/}
fi
echo "Setting version to ${VERSION}"
OTHER_VERSION="0.REVOLSYS-${VERSION}"
sed -i "s/<org.jeometry.version>.*<\\/org.jeometry.version>/<org.jeometry.version>${OTHER_VERSION}<\\/org.jeometry.version>/g" ./revolsys/pom.xml
mvn -f ./jeometry/pom.xml -B -q versions:set "-DnewVersion=${OTHER_VERSION}" -DgenerateBackupPoms=false -DprocessDependencies=false
mvn -f ./revolsys/pom.xml -B -q versions:set "-DnewVersion=${VERSION}" -DgenerateBackupPoms=false -DprocessDependencies=false
echo "OTHER_VERSION=$OTHER_VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Git Tag
run: |
git -C ./jeometry commit -a -m "Version ${OTHER_VERSION}"
git -C ./revolsys commit -a -m "Version ${VERSION}"
git -C ./jeometry tag -f "${OTHER_VERSION}"
git -C ./revolsys tag -f "${VERSION}"
git -C ./jeometry push "https://${USERNAME}:${REPO_KEY}@github.com/jeometry-org/jeometry.git" "$OTHER_VERSION"
git -C ./revolsys push "https://${USERNAME}:${REPO_KEY}@github.com/revolsys/com.revolsys.open.git" "$VERSION"
env:
USERNAME: ${{github.actor}}
REPO_KEY: ${{secrets.PUSH_TOKEN}}
#### MAVEN REPOSITORY CACHE ####
- uses: actions/cache@v3
with:
path: |
'~/.m2/repository'
'!~/.m2/repository/org/jeometry'
'!~/.m2/repository/com/revolsys/open'
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
#### Get Project Version ####
- name: Get Project Version
working-directory: ./revolsys
run: echo "PROJECT_VERSION=$(grep version pom.xml|head -1 | sed 's/<\/*version>//g' | sed 's/ //g')" >> $GITHUB_ENV
#### Set Snapshot Version ####
- name: Set Snapshot Version
if: contains(env.PROJECT_VERSION, 'SNAPSHOT')
run: |
BASE_REF=$(echo "$REF" | tr '[:lower:]' '[:upper:]')
OTHER_VERSION="0.REVOLSYS-${BASE_REF}-SNAPSHOT"
VERSION="${BASE_REF}-SNAPSHOT"
sed -i "s/<org.jeometry.version>.*<\\/org.jeometry.version>/<org.jeometry.version>${OTHER_VERSION}<\\/org.jeometry.version>/g" ./revolsys/pom.xml
mvn -f ./jeometry/pom.xml -B -q versions:set "-DnewVersion=${OTHER_VERSION}" -DgenerateBackupPoms=false -DprocessDependencies=false
mvn -f ./revolsys/pom.xml -B -q versions:set "-DnewVersion=${VERSION}" -DgenerateBackupPoms=false -DprocessDependencies=false
#### Build ####
- name: Build
working-directory: ./revolsys
run: mvn -B -ntp install -DskipTests