generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (58 loc) · 2.53 KB
/
prerelease.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Prerelease
on:
workflow_run:
workflows: [Build]
types: [completed]
jobs:
# Prepare a draft release for GitHub Releases page for the manual verification
# If accepted and published, release workflow would be triggered
releaseDraft:
name: Release Draft
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Check out the current repository
- name: Fetch Sources
uses: actions/checkout@v4
# Remove old release drafts by using the curl request for the available releases with a draft flag
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
- name: Download plugin
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{github.event.workflow_run.head_sha}}
name: ".+[Ss]urveyor-\\d.+"
name_is_regexp: true
path: plugin-artifact
- name: Extract manifest data
id: prepare
run: |
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
echo "version=$(yq '.Version' ${{ github.workspace }}/plugin-artifact/META-INF/MANIFEST.MF)" >> "$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"
rm -r ${{ github.workspace }}/plugin-artifact
# Create a new release draft which is not publicly visible and requires manual acceptance
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.prepare.outputs.version }}" \
--draft \
--title "v${{ steps.prepare.outputs.version }}" \
--notes "$(cat << 'EOM'
${{ steps.prepare.outputs.changelog }}
EOM
)"