Skip to content

Commit 0ae2b13

Browse files
committed
Create release.yml
1 parent 8739d9c commit 0ae2b13

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
2+
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
3+
4+
name: Release
5+
on:
6+
release:
7+
types: [prereleased, released]
8+
9+
jobs:
10+
11+
# Prepare and publish the plugin to the Marketplace repository
12+
release:
13+
name: Publish Plugin
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
steps:
19+
20+
# Check out current repository
21+
- name: Fetch Sources
22+
uses: actions/checkout@v3
23+
with:
24+
ref: ${{ github.event.release.tag_name }}
25+
26+
# Setup Java 11 environment for the next steps
27+
- name: Setup Java
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: zulu
31+
java-version: 11
32+
33+
# Set environment variables
34+
- name: Export Properties
35+
id: properties
36+
shell: bash
37+
run: |
38+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
39+
${{ github.event.release.body }}
40+
EOM
41+
)"
42+
43+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
44+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
45+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
46+
47+
echo "::set-output name=changelog::$CHANGELOG"
48+
49+
# Update Unreleased section with the current release note
50+
- name: Patch Changelog
51+
if: ${{ steps.properties.outputs.changelog != '' }}
52+
env:
53+
CHANGELOG: ${{ steps.properties.outputs.changelog }}
54+
run: |
55+
./gradlew patchChangelog --release-note="$CHANGELOG"
56+
57+
# Publish the plugin to the Marketplace
58+
- name: Publish Plugin
59+
env:
60+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
61+
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
62+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
63+
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
64+
run: ./gradlew publishPlugin
65+
66+
# Upload artifact as a release asset
67+
- name: Upload Release Asset
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
71+
72+
# Create pull request
73+
- name: Create Pull Request
74+
if: ${{ steps.properties.outputs.changelog != '' }}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
VERSION="${{ github.event.release.tag_name }}"
79+
BRANCH="changelog-update-$VERSION"
80+
81+
git config user.email "action@github.com"
82+
git config user.name "GitHub Action"
83+
84+
git checkout -b $BRANCH
85+
git commit -am "Changelog update - $VERSION"
86+
git push --set-upstream origin $BRANCH
87+
88+
gh pr create \
89+
--title "Changelog update - \`$VERSION\`" \
90+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
91+
--base main \
92+
--head $BRANCH

0 commit comments

Comments
 (0)