-
Notifications
You must be signed in to change notification settings - Fork 1
174 lines (151 loc) · 6.82 KB
/
build.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
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
server-id: coremedia.external.releases
server-username: PLUGINS_NEXUS_USER
server-password: PLUGINS_NEXUS_PASSWORD
- name: Cache Maven Repo
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Setup PNPM
run: |
NPM_AUTH_TOKEN=$(curl -s -H "Accept: application/json" -H "Content-Type:application/json" -X PUT --data '{"name": "${{ secrets.CM_NPM_USER }}", "password": "${{ secrets.CM_NPM_READ_ONLY_PASSWORD }}"}' https://npm.coremedia.io/-/user/org.couchdb.user:${{ secrets.CM_NPM_USER }} | jq -r .token)
echo "::add-mask::$NPM_AUTH_TOKEN"
echo "NPM_CONFIG_//npm.coremedia.io/:_authToken=$NPM_AUTH_TOKEN" >> $GITHUB_ENV
npm install -g pnpm@latest
- name: Setup Git
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
run: |
git config --global user.name 'coremedia-ci'
git config --global user.email '[email protected]'
- name: Install PNPM Dependencies
working-directory: studio-client
env:
NPM_CONFIG_@coremedia:registry: 'https://npm.coremedia.io'
NPM_CONFIG_@jangaroo:registry: 'https://npm.coremedia.io'
run: pnpm install
- name: Set Release Version
id: set-release-version
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
env:
PLUGINS_NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }}
PLUGINS_NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }}
run: |
mvn --batch-mode org.codehaus.mojo:versions-maven-plugin:2.8.1:set -DremoveSnapshot -DartifactId='*'
release_version=$(mvn --batch-mode org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
cd studio-client
pnpm set-version ${release_version}
cd ..
git add .
git commit -m "set release version: ${release_version}"
release_tag="v${release_version}"
git tag "${release_tag}"
echo "::set-output name=version::${release_version}"
echo "::set-output name=tag::${release_tag}"
- name: Output Version
id: output-version
env:
PLUGINS_NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }}
PLUGINS_NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }}
run: |
version=$(mvn --batch-mode org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo "::set-output name=version::${version}"
- name: Build with Pnpm
working-directory: studio-client
run: |
pnpm -r build
pnpm -r package
- name: Build with Maven
env:
PLUGINS_NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }}
PLUGINS_NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }}
run: mvn --batch-mode --update-snapshots verify
- name: Update license info
if: github.event_name == 'pull_request'
env:
PLUGINS_NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }}
PLUGINS_NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }}
run: |
mvn --batch-mode -Pdocs-third-party generate-resources
if [ -n "$(git status --porcelain documentation)" ]; then
git add documentation
git commit -m "update license information"
git push
fi
- name: Create Bundle
env:
VERSION: ${{ steps.output-version.outputs.version }}
DESCRIPTOR_TEMPLATE: 'feedback-hub-adapter-acrolinx.json'
CREATE_RELEASE: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
RELEASE_TAG: ${{ steps.set-release-version.outputs.tag }}
URL_PATTERN: 'https://github.com/${GITHUB_REPOSITORY}/releases/download/${RELEASE_TAG}/${REL_FILE}'
run: |
mkdir -p target/bundle
RESULT="$(cat ${DESCRIPTOR_TEMPLATE})"
APPS=$(cat ${DESCRIPTOR_TEMPLATE} | jq -r '.plugins | keys[]')
for APP in ${APPS}; do
FILE_TEMPLATE=$(cat ${DESCRIPTOR_TEMPLATE} | jq -r --arg APP "${APP}" '.plugins[$APP].file')
FILE=$(eval echo ${FILE_TEMPLATE})
REL_FILE=$(echo "${FILE}" | sed 's#.*/##g')
cp "${FILE}" target/bundle
if [ "${CREATE_RELEASE}" = true ]; then
URL=$(eval echo ${URL_PATTERN})
RESULT="$(echo ${RESULT} | jq -r --arg APP "${APP}" --arg URL "${URL}" '.plugins[$APP] = {"url": $URL}')"
else
RESULT="$(echo ${RESULT} | jq -r --arg APP "${APP}" --arg REL_FILE "${REL_FILE}" '.plugins[$APP] = {"file": $REL_FILE}')"
fi
done
echo "${RESULT}" > "target/bundle/$(echo ${DESCRIPTOR_TEMPLATE} | sed 's#.*/##g' | cut -d '.' -f1)-${VERSION}.json"
- name: Set Next Snapshot Version
id: set-snapshot-version
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
env:
PLUGINS_NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }}
PLUGINS_NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }}
run: |
mvn --batch-mode org.codehaus.mojo:versions-maven-plugin:2.8.1:set -DnextSnapshot -DartifactId='*'
snapshot_version=$(mvn --batch-mode org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
cd studio-client
pnpm set-version ${snapshot_version}
cd ..
git add .
git commit -m "set next snapshot version"
git push && git push --tags
echo "::set-output name=version::${snapshot_version}"
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: feedback-hub-adapter-acrolinx-${{ steps.output-version.outputs.version }}
path: target/bundle
if-no-files-found: error
- name: Upload Release Artifacts
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.set-release-version.outputs.version }}
files: target/bundle/*