Skip to content

Release Integrations without JEC scripts #6

Release Integrations without JEC scripts

Release Integrations without JEC scripts #6

name: Release Integrations without JEC scripts
on:
workflow_dispatch:
inputs:
integration:
description: 'Integration Type'
required: true
type: choice
options:
- opsview
- vcenter
- vcsa
- oem
workflow_call:
inputs:
integration:
description: 'Integration Type'
required: true
type: string
is_workflow_call:
description: 'To distinguish workflow_call from other events'
type: boolean
required: false
default: true
permissions:
pull-requests: write
contents: write
jobs:
setup:
name: Setup For ${{ inputs.integration }} Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
integration_name: ${{ steps.gather_params.outputs.INTEGRATION_NAME }}
integration_version: ${{ steps.gather_params.outputs.INTEGRATION_VERSION }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Retrieve Integration Version
id: gather_params
run: |
echo ::set-output name=INTEGRATION_VERSION::$(jq -r --arg v "${{ inputs.integration }}" '.[$v]' release/integration-builder/version.json)
echo ::set-output name=INTEGRATION_NAME::$(echo "${{ inputs.integration }}" | awk '{print tolower($0)}')
- name: Create ${{ inputs.integration }} Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INTEGRATION_VERSION: ${{ steps.gather_params.outputs.INTEGRATION_VERSION }}
INTEGRATION_NAME: ${{ inputs.integration }}
with:
tag_name: jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}
release_name: jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}
draft: true
build-gradle-project:
name: Build gradle project
runs-on: ubuntu-latest
needs: [setup]
env:
INTEGRATION_NAME: ${{ needs.setup.outputs.integration_name }}
INTEGRATION_VERSION: ${{ needs.setup.outputs.integration_version }}
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout project sources
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'temurin'
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15.7
id: go
- name: Create Go Build Output Directory
run: mkdir -p ./go-build/${{ env.INTEGRATION_NAME }}
- name: Copy Integration Files
run: cp -R ${{ inputs.integration }}/. ./go-build/${{ env.INTEGRATION_NAME }}
- name: "Build Linux Go scripts"
if: ${{env.INTEGRATION_NAME != 'vcenter'}}
run: |
go get -u github.com/alexcesaro/log && \
cd ./go-build/${{ env.INTEGRATION_NAME }}/scripts && \
GOOS=linux GOARCH=amd64 go build -o send2jsm send2jsm.go
- name: "Build Windows Go scripts"
if: ${{env.INTEGRATION_NAME == 'vcenter'}}
run: |
go get -u github.com/alexcesaro/log && \
cd ./go-build/${{ env.INTEGRATION_NAME }}/scripts && \
GOOS=windows GOARCH=386 go build -o send2jsm.exe send2jsm.go
- name: Upload Go Build Files
uses: actions/upload-artifact@v4
with:
name: Build Go Artifact
path: ./go-build/${{ env.INTEGRATION_NAME }}/*
- name: Copy Gradle Files
run: cp -R release/integration-builder/. ./
- name: Copy Integration Files with Builds
run: cp -R ./go-build/${{ env.INTEGRATION_NAME }}/* ./${{ env.INTEGRATION_NAME }}/
- name: Remove old builds
run: rm -rf build
- name: Build with Gradle
run:
./gradlew ${{ env.INTEGRATION_NAME }}
- name: Upload Build Files
uses: actions/upload-artifact@v4
with:
name: Build Files Artifact
path: build/*
- name: Upload Red Hat 6 Based Artifact
if: ${{env.INTEGRATION_NAME != 'vcenter'}}
uses: actions/upload-artifact@v4
with:
name: RHEL6 Artifact
path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}-1.all.noarch.rpm
- name: Release RHEL6 package
if: ${{env.INTEGRATION_NAME != 'vcenter'}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.upload_url }}
asset_path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}-1.all.noarch.rpm
asset_name: jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}-1.all.noarch.rpm
asset_content_type: application/octet-stream
- name: Upload Debian Based Artifact
if: ${{env.INTEGRATION_NAME != 'vcsa' && env.INTEGRATION_NAME != 'vcenter'}}
uses: actions/upload-artifact@v4
with:
name: Debian Artifact
path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}_${{ env.INTEGRATION_VERSION }}_all.deb
- name: Release Debian package
if: ${{env.INTEGRATION_NAME != 'vcsa' && env.INTEGRATION_NAME != 'vcenter'}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.upload_url }}
asset_path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}_${{ env.INTEGRATION_VERSION }}_all.deb
asset_name: jsm-${{ env.INTEGRATION_NAME }}_${{ env.INTEGRATION_VERSION }}_all.deb
asset_content_type: application/octet-stream
- name: Upload Win64 Based Artifact
if: ${{env.INTEGRATION_NAME == 'vcenter'}}
uses: actions/upload-artifact@v4
with:
name: Win64 Artifact
path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}.zip
- name: Release Win64 Package
if: ${{env.INTEGRATION_NAME == 'vcenter'}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.upload_url }}
asset_path: build/distributions/jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}.zip
asset_name: jsm-${{ env.INTEGRATION_NAME }}-${{ env.INTEGRATION_VERSION }}.zip
asset_content_type: application/zip
update-versions:
name: Update versions
runs-on: ubuntu-latest
needs: [ setup ]
env:
INTEGRATION_NAME: ${{ needs.setup.outputs.integration_name }}
if: github.ref == 'refs/heads/master' && inputs.is_workflow_call != true
steps:
- name: Checkout the repository with branch
uses: actions/checkout@v4
- name: Set branch name to env
id: prepare-branch-name
run: |
branchName=release-${INTEGRATION_NAME}-$(date +%s)
echo branchName:$branchName
echo ::set-output name=BRANCH_NAME::$(echo $branchName)
- name: Commit and push changes
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ steps.prepare-branch-name.outputs.branch_name }}
run: |
INTEGRATION_NAME=${{ env.INTEGRATION_NAME }}
BRANCH_NAME=${{ env.BRANCH_NAME }}
version_file="release/integration-builder/version.json"
git config --global user.name 'Github Actions'
git config --global user.email '[email protected]'
git checkout "$BRANCH_NAME" 2>/dev/null || git checkout -b "$BRANCH_NAME"
current_version=$(jq -r --arg integration "$INTEGRATION_NAME" '.[$integration]' "$version_file")
new_version=$(echo "$current_version" | awk -F. -v OFS=. '{$3++;print}')
echo "Updating $INTEGRATION_NAME version from $current_version to $new_version in $version_file"
jq --arg new_version "$new_version" --arg integration "$INTEGRATION_NAME" '.[$integration] = $new_version' "$version_file" >temp.json && mv temp.json "$version_file"
git commit -am "Update version file after release(s)"
git push origin "$BRANCH_NAME"
gh pr create --title "Update $INTEGRATION_NAME version" \
--body "Update $INTEGRATION_NAME version from $current_version to $new_version" \
--base master \
--head $BRANCH_NAME \
--reviewer ${{ github.actor }}