Skip to content

Commit

Permalink
Update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TarCV committed May 25, 2023
1 parent dd2a673 commit 60b201a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ jobs:
FILENAME=`ls *.zip`
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
- name: Compute sha256sum for the artifact
run: |
echo 'sha256sum of the artifact (please compare this sum with the sum from Garnix workflow):'
sha256sum -b "$(find ./plugin/build/distributions/*)"
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nix-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ jobs:
fi
ls --almost-all --format=long --recursive .
[[ -d ./artefact ]]
- name: Compute sha256sum for the artifact from Garnix
run: |
echo 'sha256sum of the artifact built in Garnix:'
sha256sum -b "$(find artefact/*)"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down
113 changes: 62 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,91 @@ jobs:
release:
name: Publish Plugin
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
permissions:
contents: write
pull-requests: write
steps:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}

# Setup Java 11 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11

# 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
)"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Update Unreleased section with the current release note
- name: Patch Changelog
if: ${{ steps.properties.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.properties.outputs.changelog }}
run: |
./gradlew patchChangelog --release-note="$CHANGELOG"
ref: ${{ env.GITHUB_SHA }}

- name: Download plugin
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{github.event.release.tag_name}}
commit: ${{ env.GITHUB_SHA }}
name: ".+[Ss]urveyor-\\d.+"
name_is_regexp: true
path: plugin-artifact

# Publish the plugin to the Marketplace
# - name: Publish Plugin
# TODO: Revert back to publishing the plugin
- name: Build release version of plugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: ./gradlew -x buildPlugin signPlugin
#- name: Build release version of plugin
# env:
# PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
# CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
# PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
# PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
# run: ./gradlew -x buildPlugin signPlugin

# Upload artifact as a release asset
- name: Extract manifest data
id: prepare
run: |
set -x
unzip "$(find ${{ github.workspace }}/plugin-artifact/*/*.zip)" -d ${{ github.workspace }}/plugin-artifact
unzip "$(find ${{ github.workspace }}/plugin-artifact/*/lib/instrumented-plugin-*.jar)" -d ${{ github.workspace }}/plugin-artifact
VERSION=$(yq '.Version' ${{ github.workspace }}/plugin-artifact/META-INF/MANIFEST.MF)
[[ "v$VERSION" == "$RELEASE_TAG" ]]
[[ "$(git rev-list -n 1 "v$VERSION")" == "$GITHUB_SHA" ]]
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changelog<<$EOF" >> "$GITHUB_OUTPUT"
yq -p=xml -o=yaml '.idea-plugin.change-notes' ${{ github.workspace }}/plugin-artifact/META-INF/plugin.xml >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./plugin/build/distributions/*
run: |
echo 'sha256sum of the uploaded file is (please compare this sum with the sum from Garnix workflow):'
sha256sum -b "$(find ${{ github.workspace }}/plugin-artifact/*/*.zip)"
gh release upload $RELEASE_TAG "$(find ${{ github.workspace }}/plugin-artifact/*/*.zip)"
# Create pull request
- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
# Create a branch for PR updating Unreleased section with the current release note
- name: Fetch Sources
uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_SHA }}
- name: Gradle Wrapper Validation
uses: gradle/[email protected]
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Patch Changelog
if: ${{ steps.prepare.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.prepare.outputs.changelog }}
run: |
./gradlew patchChangelog
- name: Create a Branch for a Pull Request
if: ${{ steps.prepare.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="$RELEASE_TAG"
BRANCH="changelog-update-$VERSION"
LABEL="release changelog"
Expand All @@ -100,11 +112,11 @@ jobs:
--description "Pull requests with release changelog update" \
|| true
gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--label "$LABEL" \
--head $BRANCH
# gh pr create \
# --title "Changelog update - \`$VERSION\`" \
# --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
# --label "$LABEL" \
# --head $BRANCH

- name: Collect Dependency Verification Errors
if: ${{ failure() }}
Expand All @@ -114,4 +126,3 @@ jobs:
path: |
${{ github.workspace }}/build/reports/dependency-verification
${{ github.workspace }}/**/build/reports/dependency-verification

0 comments on commit 60b201a

Please sign in to comment.