Skip to content

Create new monthly Release (automated) #41

Create new monthly Release (automated)

Create new monthly Release (automated) #41

Workflow file for this run

name: Create new monthly Release (automated)
on:
repository_dispatch:
types: perform-release
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
create-release:
runs-on: ubuntu-latest
strategy:
matrix:
base-image-tag: [16-bullseye, 18-bullseye, 16-bookworm, 18-bookworm, 20-bookworm]
steps:
- uses: actions/checkout@v3
- name: Determine Java version
id: java_version
run: |
if [[ "${{ matrix.base-image-tag }}" == *"-bullseye" ]]; then
echo 'version=11' >> $GITHUB_OUTPUT
else
echo 'version=17' >> $GITHUB_OUTPUT
fi
- name: Test
run: |
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }} ${{ steps.java_version.outputs.version }}
- name: Prepare Release
run: |
CURRENT_VERSION_LONG=$(curl --silent "https://api.github.com/repos/SAP/devops-docker-node-browsers/releases" | jq -r '.[].tag_name' | head -n1)
echo Current version: $CURRENT_VERSION_LONG
CURRENT_VERSION=`echo $CURRENT_VERSION_LONG | cut -c 2- | cut -d. -f1`
NEXT_VERSION=v$(expr $CURRENT_VERSION + 1)
echo Next version: $NEXT_VERSION
STATUS_CODE_FOR_NEXT_RELEASE=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/SAP/devops-docker-node-browsers/releases/tags/$NEXT_VERSION")
if [ "$STATUS_CODE_FOR_NEXT_RELEASE" != "404" ]; then
echo "Planned next release version ($NEXT_VERSION) already exists, aborting process"
exit 1
fi
echo "PIPER_version=$NEXT_VERSION" >> $GITHUB_ENV
- name: Build and push
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USER }} --password-stdin
echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --build-arg=JAVA_VERSION=${{ steps.java_version.outputs.version }} --tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} .
docker tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
docker push ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
docker push ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
- name: Tag and push node 20 image
if: ${{ matrix.base-image-tag == '20-bookworm' }}
run: |
docker tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ppiper/node-browsers:${{ env.PIPER_version }}
docker tag ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}
docker push ppiper/node-browsers:${{ env.PIPER_version }}
docker push ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}
- uses: SAP/project-piper-action@master
if: ${{ matrix.base-image-tag == '20-bookworm' }}
with:
piper-version: latest
command: githubPublishRelease
flags: --token ${{ secrets.GITHUB_TOKEN }}