|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + BASE_IMAGE_NAME: ghcr.io/oracle/weblogic-kubernetes-operator |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: "Set environmental variables" |
| 17 | + run: | |
| 18 | + VERSION=${GITHUB_REF_NAME#v} |
| 19 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 20 | + echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:$VERSION" >> $GITHUB_ENV |
| 21 | +
|
| 22 | + - name: Checkout branch |
| 23 | + uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Set up JDK |
| 26 | + uses: actions/setup-java@v3 |
| 27 | + with: |
| 28 | + distribution: 'temurin' |
| 29 | + java-version: 17 |
| 30 | + |
| 31 | + - name: Cache Maven packages |
| 32 | + uses: actions/cache@v3 |
| 33 | + with: |
| 34 | + path: ~/.m2 |
| 35 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 36 | + restore-keys: ${{ runner.os }}-m2 |
| 37 | + |
| 38 | + - name: Build |
| 39 | + env: |
| 40 | + GITHUB_TOKEN: ${{ secrets.PUBLISH_SECRET }} |
| 41 | + run: mvn clean package -Dtag=${{ env.VERSION }} |
| 42 | + |
| 43 | + - name: Create Draft Release |
| 44 | + id: draft-release |
| 45 | + run: | |
| 46 | + echo 'PR_URL<<EOF' >> $GITHUB_ENV |
| 47 | + gh release create ${{ github.ref_name }} \ |
| 48 | + --draft \ |
| 49 | + --generate-notes \ |
| 50 | + --target release/4.1 \ |
| 51 | + --title 'Operator ${{ env.VERSION }}' \ |
| 52 | + --repo https://github.com/oracle/weblogic-kubernetes-operator |
| 53 | + echo 'EOF' >> $GITHUB_ENV |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Set up QEMU |
| 58 | + uses: docker/setup-qemu-action@v2 |
| 59 | + |
| 60 | + - name: Set up Buildx |
| 61 | + uses: docker/setup-buildx-action@v2 |
| 62 | + |
| 63 | + - name: Log in to the Container registry |
| 64 | + uses: docker/login-action@v2 |
| 65 | + with: |
| 66 | + registry: ${{ env.REGISTRY }} |
| 67 | + username: ${{ github.actor }} |
| 68 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + |
| 70 | + - name: Build and push container image |
| 71 | + uses: docker/build-push-action@v4 |
| 72 | + with: |
| 73 | + context: . |
| 74 | + platforms: linux/amd64,linux/arm64 |
| 75 | + push: true |
| 76 | + tags: ${{ env.IMAGE_NAME }} |
| 77 | + |
| 78 | + - name: Checkout gh-pages |
| 79 | + uses: actions/checkout@v3 |
| 80 | + with: |
| 81 | + ref: gh-pages |
| 82 | + path: gh-pages |
| 83 | + token: ${{ secrets.PUBLISH_SECRET }} |
| 84 | + |
| 85 | + - name: Generate and publish Helm chart |
| 86 | + run: | |
| 87 | + curl -fL -o helm.tar.gz "https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz" |
| 88 | + tar -xf helm.tar.gz |
| 89 | + export PATH="$PWD/linux-amd64:$PATH" |
| 90 | + sed -i 's#4.1.0-RELEASE-MARKER#${{ env.BASE_IMAGE_NAME }}:$VERSION#g' $GITHUB_WORKSPACE/kubernetes/charts/weblogic-operator/values.yaml |
| 91 | + mkdir $GITHUB_WORKSPACE/WORK |
| 92 | + helm package --app-version $VERSION --version $VERSION $GITHUB_WORKSPACE/kubernetes/charts/weblogic-operator -d $GITHUB_WORKSPACE/WORK |
| 93 | + cp $GITHUB_WORKSPACE/WORK/*.tgz $GITHUB_WORKSPACE/gh-pages/charts/ |
| 94 | + helm repo index $GITHUB_WORKSPACE/gh-pages/charts/ --url https://oracle.github.io/weblogic-kubernetes-operator/charts |
| 95 | + cd $GITHUB_WORKSPACE/gh-pages |
| 96 | + git config --global user.name "github-actions[bot]" |
| 97 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 98 | + git add --all |
| 99 | + git commit -m "Helm chart update from release GitHub Action" |
| 100 | + git push origin gh-pages |
0 commit comments