forked from javaparser/javaparser
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (66 loc) · 2.67 KB
/
prepare_release_changelog.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
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Build Snapshot
on:
push:
branches: [ master ]
## (testing only) Trigger the workflow on any pull request
#pull_request:
jobs:
generate_changelog:
name: Generate Changelog
runs-on: ubuntu-latest
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/[email protected]
# Setup Java 11 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
# Set environment variables
- name: Generate Changelog
id: vars
shell: bash
working-directory: ./scripts
run: |
## By convention, the "next" milestone is named "next release"
./run_generate_changelog_by_milestone_title.sh "next release"
SHA_LONG=$(git rev-parse HEAD)
SHA_SHORT=$(git rev-parse --short HEAD)
CHANGELOG="$(<temp_changelog.md)"
RELEASE_TITLE="SNAPSHOT - $SHA_SHORT"
RELEASE_TAG_NAME="v_snapshot_$SHA_SHORT"
echo "sha_long=$SHA_LONG" >> $GITHUB_OUTPUT
echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "release_title=$RELEASE_TITLE" >> $GITHUB_OUTPUT
echo "release_tag_name=$RELEASE_TAG_NAME" >> $GITHUB_OUTPUT
- name: Output variables
run: |
echo sha_short = ${{ steps.vars.outputs.sha_short }}
echo sha_long = ${{ steps.vars.outputs.sha_long }}
echo changelog = "${{ steps.vars.outputs.changelog }}"
echo changelog = "${{ steps.vars.outputs.release_title }}"
echo changelog = "${{ steps.vars.outputs.release_tag_name }}"
# Remove old release drafts by using the curl request for the available releases with 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/{}
# Create 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 ${{ steps.vars.outputs.release_tag_name }} \
--target ${{ steps.vars.outputs.sha_long }} \
--draft \
--prerelease \
--title "${{ steps.vars.outputs.release_title }}" \
--notes-file ./scripts/temp_changelog.md