Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSM-461 Added GitHub action to build and release ServiceNow plugin #522

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/publish.servicenow.plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release Keeper ServiceNow Plugin

on:
workflow_dispatch:
inputs:
tagname:
type: string
required: true
description: New tag name for the release

jobs:
publish-servicenow-plugin:
environment: prod
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./integration/servicenow-external-credential-resolver

steps:
- name: Get the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true

- name: Validate Release Tag
run: |
TAG="${{ github.event.inputs.tagname }}"
git check-ref-format "tags/${TAG}" && echo "Valid release tag ${TAG}" || echo "Invalid release tag ${TAG}"
git check-ref-format "tags/${TAG}"

- name: Check if new release tag already exists
run: |
git fetch --tags --quiet
TAG="${{ github.event.inputs.tagname }}"
git show-ref --tags --verify --quiet "refs/tags/${TAG}" && echo "The new release tag already exists" || echo "The new release tag does not exist"
! git show-ref --tags --verify --quiet "refs/tags/${TAG}"

- name: Check if version is included in the new release tag
if: ${{ false }} # disable for now
run: |
TAG="${{ github.event.inputs.tagname }}"
GRADLE_CFG=./build.gradle
BUILD_VERSION=`fgrep version $GRADLE_CFG | sed -r 's/^version\s+//g' | sed "s/'//g"`
if [[ "$TAG" == *"-$BUILD_VERSION"* ]]; then
echo "Build version $BUILD_VERSION is included in the tag $TAG"
else
echo "Build version $BUILD_VERSION is not included in the tag $TAG"
exit 1
fi

- name: Create Shell Script
run: |
cat <<'EOF' > build.sh
#!/usr/bin/env bash
MID_SERVER_URLS=''
MID_SERVER_URLS=${MID_SERVER_URLS},https://install.service-now.com/glide/distribution/builds/package/mid/2023/08/20/mid.utah-12-21-2022__patch6-08-09-2023_08-20-2023_0545.linux.x86-64.zip
MID_SERVER_URLS=${MID_SERVER_URLS},https://install.service-now.com/glide/distribution/builds/package/mid/2023/06/23/mid.tokyo-07-08-2022__patch9-hotfix2-06-07-2023_06-23-2023_1740.linux.x86-64.zip
MID_SERVER_URLS=${MID_SERVER_URLS},https://install.service-now.com/glide/distribution/builds/package/mid/2023/03/07/mid.sandiego-12-22-2021__patch10-hotfix2-03-06-2023_03-07-2023_0439.linux.x86-64.zip
MID_SERVER_URLS=${MID_SERVER_URLS},https://install.service-now.com/glide/distribution/builds/package/mid/2022/07/21/mid.rome-06-23-2021__patch10-07-13-2022_07-21-2022_1153.linux.x86-64.zip

releasedir=`pwd`/releases
mkdir -p ${releasedir}
midsdir=`pwd`/mids
mkdir -p ${midsdir}
buildroot=`pwd`

chmod u+x ${buildroot}/gradlew
gradlecfg=${buildroot}/build.gradle

buildname=`fgrep archivesName ${gradlecfg} | sed -r 's/^\s*archivesName\s*=\s*//g' | sed "s/'//g"`
buildversion=`fgrep version ${gradlecfg} | sed -r 's/^version\s+//g' | sed "s/'//g"`
srcjarpath=${buildroot}/build/libs/${buildname}-${buildversion}.jar

IFS="," read -a urls <<< ${MID_SERVER_URLS}
for url in "${urls[@]}"; do
if [[ -n "${url// }" ]] ; then
cd ${midsdir}
filename=${url##*/}
tmp=${url##*/mid.}
version=${tmp%%-*}

curl -L -O -C - ${url}
unzip -qq -o -d ${midsdir}/${version} ${filename}

libpath=${midsdir}/${version}/agent/lib
elibpath=${libpath//\//\\/}
sed -i "s/def midserver_agent_dir =.*/def midserver_agent_dir = \'${elibpath}\'/" ${gradlecfg}

cd ${buildroot}
./gradlew jar || echo "Build Failed!"; exit 1

dstjarpath=${releasedir}/${buildname}-${version}-${buildversion}.jar
mv ${srcjarpath} ${dstjarpath} || echo "File Copy Failed!"; exit 1
fi
done
EOF

- name: Run Shell Script
run: |
chmod u+x build.sh
./build.sh

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ github.event.inputs.tagname }}"
GRADLE_CFG=./build.gradle
BUILD_NAME=`fgrep archivesName $GRADLE_CFG | sed -r 's/^\s*archivesName\s*=\s*//g' | sed "s/'//g"`
BUILD_VERSION=`fgrep version $GRADLE_CFG | sed -r 's/^version\s+//g' | sed "s/'//g"`
RELEASE_NAME=${BUILD_NAME}-${BUILD_VERSION}.jar
gh release create ${TAG} `pwd`/releases/*.jar --repo="$GITHUB_REPOSITORY" --title="$RELEASE_NAME" --generate-notes
Loading