2020-06-17 19:06:57 +00:00
|
|
|
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
|
|
|
|
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
|
|
|
|
|
2020-06-17 05:19:59 +00:00
|
|
|
name: Release
|
|
|
|
on:
|
|
|
|
release:
|
2020-07-06 20:02:43 +00:00
|
|
|
types: [prereleased, released]
|
2020-06-17 05:19:59 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-06-19 07:51:04 +00:00
|
|
|
|
|
|
|
# Prepare and publish the plugin to the Marketplace repository
|
2020-06-17 05:19:59 +00:00
|
|
|
release:
|
|
|
|
name: Publish Plugin
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
|
|
|
# Check out current repository
|
|
|
|
- name: Fetch Sources
|
2022-03-02 06:30:33 +00:00
|
|
|
uses: actions/checkout@v3
|
2020-06-22 20:19:50 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.release.tag_name }}
|
2020-06-17 05:19:59 +00:00
|
|
|
|
2021-08-31 07:04:03 +00:00
|
|
|
# Setup Java 11 environment for the next steps
|
|
|
|
- name: Setup Java
|
|
|
|
uses: actions/setup-java@v2
|
2021-08-26 14:48:38 +00:00
|
|
|
with:
|
2021-08-31 07:04:03 +00:00
|
|
|
distribution: zulu
|
|
|
|
java-version: 11
|
|
|
|
cache: gradle
|
2021-08-26 14:48:38 +00:00
|
|
|
|
2021-10-14 11:29:30 +00:00
|
|
|
# Set environment variables
|
|
|
|
- name: Export Properties
|
|
|
|
id: properties
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
|
|
|
|
${{ github.event.release.body }}
|
|
|
|
EOM
|
|
|
|
)"
|
|
|
|
|
2021-11-25 12:06:49 +00:00
|
|
|
CHANGELOG="${CHANGELOG//'%'/'%25'}"
|
|
|
|
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
|
|
|
|
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
|
|
|
|
|
2021-10-14 11:29:30 +00:00
|
|
|
echo "::set-output name=changelog::$CHANGELOG"
|
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
# Update Unreleased section with the current release note
|
|
|
|
- name: Patch Changelog
|
2021-10-14 11:29:30 +00:00
|
|
|
if: ${{ steps.properties.outputs.changelog != '' }}
|
2021-11-25 12:06:49 +00:00
|
|
|
env:
|
|
|
|
CHANGELOG: ${{ steps.properties.outputs.changelog }}
|
2021-08-26 14:48:38 +00:00
|
|
|
run: |
|
2021-11-25 12:06:49 +00:00
|
|
|
./gradlew patchChangelog --release-note="$CHANGELOG"
|
2021-08-26 14:48:38 +00:00
|
|
|
|
2020-06-19 07:51:04 +00:00
|
|
|
# Publish the plugin to the Marketplace
|
2020-06-17 05:19:59 +00:00
|
|
|
- name: Publish Plugin
|
|
|
|
env:
|
|
|
|
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
|
|
|
|
run: ./gradlew publishPlugin
|
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
# Upload artifact as a release asset
|
|
|
|
- name: Upload Release Asset
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
|
2020-09-17 19:54:36 +00:00
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
# Create pull request
|
|
|
|
- name: Create Pull Request
|
2021-10-14 11:29:30 +00:00
|
|
|
if: ${{ steps.properties.outputs.changelog != '' }}
|
2021-08-26 14:48:38 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
VERSION="${{ github.event.release.tag_name }}"
|
|
|
|
BRANCH="changelog-update-$VERSION"
|
2020-07-07 04:26:29 +00:00
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
git config user.email "action@github.com"
|
|
|
|
git config user.name "GitHub Action"
|
2020-07-07 04:26:29 +00:00
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
git checkout -b $BRANCH
|
|
|
|
git commit -am "Changelog update - $VERSION"
|
|
|
|
git push --set-upstream origin $BRANCH
|
2020-06-17 05:19:59 +00:00
|
|
|
|
2021-08-26 14:48:38 +00:00
|
|
|
gh pr create \
|
|
|
|
--title "Changelog update - \`$VERSION\`" \
|
|
|
|
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
|
|
|
|
--base main \
|
|
|
|
--head $BRANCH
|