-
Notifications
You must be signed in to change notification settings - Fork 213
107 lines (94 loc) · 3.52 KB
/
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
name: Release
on:
push:
tags:
- v*
env:
REGISTRY: ghcr.io
BASE_IMAGE_NAME: ghcr.io/oracle/weblogic-kubernetes-operator
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: "Set environmental variables"
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "IMAGE_NAME=${{ env.BASE_IMAGE_NAME }}:$VERSION" >> $GITHUB_ENV
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn clean package -Dtag=${{ env.VERSION }}
cd kubernetes/samples/scripts
zip -r ../../../target/sample-scripts.zip *
cd ../../..
- name: Create Draft Release
id: draft-release
run: |
echo 'PR_URL<<EOF' >> $GITHUB_ENV
gh release create ${{ github.ref_name }} \
--draft \
--generate-notes \
--target release/4.2 \
--title 'Operator ${{ env.VERSION }}' \
--repo https://github.com/oracle/weblogic-kubernetes-operator \
domain-upgrader/target/domain-upgrader.jar \
target/sample-scripts.zip
echo 'EOF' >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PUBLISH_SECRET }}
- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ env.IMAGE_NAME }}
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate and publish Helm chart
run: |
curl -fL -o helm.tar.gz "https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz"
tar -xf helm.tar.gz
export PATH="$PWD/linux-amd64:$PATH"
sed -i 's#4.3.0-RELEASE-MARKER#${{ env.BASE_IMAGE_NAME }}:${{ env.VERSION }}#g' $GITHUB_WORKSPACE/kubernetes/charts/weblogic-operator/values.yaml
mkdir $GITHUB_WORKSPACE/WORK
helm package --app-version $VERSION --version $VERSION $GITHUB_WORKSPACE/kubernetes/charts/weblogic-operator -d $GITHUB_WORKSPACE/WORK
cp $GITHUB_WORKSPACE/WORK/*.tgz $GITHUB_WORKSPACE/gh-pages/charts/
helm repo index $GITHUB_WORKSPACE/gh-pages/charts/ --url https://oracle.github.io/weblogic-kubernetes-operator/charts
cd $GITHUB_WORKSPACE/gh-pages
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m "Helm chart update from release GitHub Action"
git push origin gh-pages