forked from liquibase/liquibase-test-harness
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (132 loc) · 4.83 KB
/
create-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
name: Release Test-Harness
on:
workflow_dispatch:
inputs:
extensionVersion:
description: 'Extension Version to release'
required: true
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
extensionVersion: ${{ steps.collect-data.outputs.extensionVersion }}
steps:
- name: Collect Data
id: collect-data
uses: actions/[email protected]
with:
script: |
if (context.payload.inputs) {
core.setOutput("extensionVersion", context.payload.inputs.extensionVersion);
} else {
core.setFailed('Unknown event type')
}
- run: |
echo "Saw Extension to release version ${{ steps.collect-data.outputs.extensionVersion }}"
build:
name: "Build and Test"
runs-on: ubuntu-latest
needs: setup
outputs:
releaseSha: ${{ steps.get-release-sha.outputs.releaseSha }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Cache Built Code
uses: actions/cache@v4
with:
key: built-code-${{ github.run_id }}
path: ./**/target
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Configure git user
run: |
git config user.name "liquibot"
git config user.email "[email protected]"
- name: Update pom.xml with release versions and commit changes
run: |
mvn -B versions:set -DnewVersion=${{ needs.setup.outputs.extensionVersion }} -DallowSnapshots=false -DoldVersion="*"
git add pom.xml
if git diff-index --cached --quiet HEAD --
then
echo "Nothing new to commit"
else
git commit -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}"
fi
git tag -a -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" liquibase-test-harness-${{ needs.setup.outputs.extensionVersion }}
git push "https://liquibot:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Get release SHA
id: get-release-sha
run: echo ::set-output name=releaseSha::$(git rev-parse HEAD)
- name: Build and Unit Test
run: mvn -B clean -Dmaven.test.skip package
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-reports-jdk
path: ./**/target/surefire-reports
- name: Save Artifacts
uses: actions/upload-artifact@v4
with:
name: liquibase-test-harness
path: |
target/*.jar
draft-release:
needs: [ setup, build ]
name: Draft Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: liquibase-test-harness
- name: Release
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ needs.build.outputs.releaseSha }}
name: v${{ needs.setup.outputs.extensionVersion }}
tag_name: liquibase-test-harness-${{ needs.setup.outputs.extensionVersion }}
draft: true
body: In version ${{ needs.setup.outputs.extensionVersion }} we
files: liquibase-test-harness-*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bump-pom-to-snapshot:
name: Prepare POM for Development
runs-on: ubuntu-latest
needs: [ draft-release ]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Configure git user
run: |
git config user.name "liquibot"
git config user.email "[email protected]"
- name: Prepare code for next version
run: |
git pull
mvn -B versions:set -DnextSnapshot=true
git add pom.xml
git commit -m "Version Bumped to Snapshot for Development"
git push "https://liquibot:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}