Skip to content

Deploy to JMeter Plugins #2

Deploy to JMeter Plugins

Deploy to JMeter Plugins #2

name: Deploy to JMeter Plugins
on: workflow_dispatch
env:
PLUGIN_ARTIFACT_NAME: "jmeter-bzm-correlation-recorder"
PLUGIN_REPOSITORY_NAME: CorrelationRecorder
JMETER_PLUGINS_PLUGIN_KEY: "bzm-siebel"
FILE_PATH: "site/dat/repo/blazemeter.json"
FORKED_REPO_SSH: "[email protected]:Abstracta/jmeter-plugins.git"
UPSTREAM_REPO_SSH: "[email protected]:undera/jmeter-plugins.git"
FORKED_REPO_USER: Abstracta
UPSTREAM_REPO_USER: undera
JMETER_PLUGINS_NAME: jmeter-plugins
jobs:
release:
runs-on: ubuntu-latest
concurrency: blazemeter_test
steps:
- name: Checkout ${{ env.PLUGIN_REPOSITORY_NAME }}
uses: actions/checkout@v4
with:
sparse-checkout: |
releases.json
.github/build_release_json.sh
sparse-checkout-cone-mode: false
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Get latest release version
id: version
run: |
echo "${{ secrets.GH_TOKEN }}" | gh auth login --with-token
RELEASE_VERSION=$(gh release view -R Blazemeter/$PLUGIN_REPOSITORY_NAME --json name -q '.name')
if [ -z "$RELEASE_VERSION" ]; then
echo "No release version found"
exit 1
fi
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Checkout forked jmeter-plugins repository
uses: actions/checkout@v4
with:
repository: ${{ env.FORKED_REPO_USER }}/${{ env.JMETER_PLUGINS_NAME }}
path: jmeter-plugins
token: ${{ secrets.GH_TOKEN }}
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Configure Git
working-directory: ./jmeter-plugins
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
env:
GITHUB_ACTOR: ${{ github.actor }}
- name: Set remotes
working-directory: ./jmeter-plugins
run: |
git remote set-url origin $FORKED_REPO_SSH
git remote add upstream $UPSTREAM_REPO_SSH
- name: Create name for branch release
working-directory: ./jmeter-plugins
run: |
echo "BRANCH_NAME=$PLUGIN_ARTIFACT_NAME-v$RELEASE_VERSION" >> $GITHUB_ENV
- name: "Create branch: ${{ env.BRANCH_NAME }}"
working-directory: ./jmeter-plugins
run: |
git checkout -b $BRANCH_NAME
- name: Update ${{ env.BRANCH_NAME }} from upstream
working-directory: ./jmeter-plugins
run: |
git fetch upstream
git merge upstream/master --allow-unrelated-histories || git merge --abort
- name: Build and save json release object
run: |
NEW_VERSION_OBJECT=$(bash .github/build_release_json.sh \
$RELEASE_VERSION \
$PLUGIN_ARTIFACT_NAME \
$PLUGIN_REPOSITORY_NAME)
if [ -z "$NEW_VERSION_OBJECT" ]; then
echo "JSON Relase object is empty. Something might gone wrong while generating it."
exit 1
fi
echo "NEW_VERSION_OBJECT=$NEW_VERSION_OBJECT" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Update jmeter-plugins JSON File
working-directory: ./jmeter-plugins
run: |
jq --argjson newVersion "$NEW_VERSION_OBJECT" \
--arg plugin_key "$JMETER_PLUGINS_PLUGIN_KEY" \
'map(if .id == $plugin_key then .versions += $newVersion else . end)' \
$FILE_PATH > tmp.json
mv tmp.json $FILE_PATH
- name: Commit and push changes
working-directory: ./jmeter-plugins
run: |
git add $FILE_PATH
git commit -m "$PLUGIN_REPOSITORY_NAME v$RELEASE_VERSION release"
git push -u origin $BRANCH_NAME
- name: "Open PR in ${{ env.UPSTREAM_REPO_USER }}/${{ env.JMETER_PLUGINS_NAME }}"
run: |
gh pr create -R $FORKED_REPO_USER/$JMETER_PLUGINS_NAME \
--title "$PLUGIN_REPOSITORY_NAME v$RELEASE_VERSION" \
--body "Automated release process" \
--head $FORKED_REPO_USER:$BRANCH_NAME \
--base master \
--repo $UPSTREAM_REPO_USER/$JMETER_PLUGINS_NAME
--draft