-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (44 loc) · 2.45 KB
/
prerelease_bash.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
name: Auto Release Notes - Bash
on:
workflow_dispatch:
jobs:
pre-release:
name: "Pre Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- name: Set Env Variables
run: |
echo "PRERELEASE_VERSION=$(echo v`date +%Y.%m.%d`.`git rev-parse --short HEAD`.rc)" >> $GITHUB_ENV
echo "RELEASE_DATE=$(echo `date +%Y\.%m\.%d`)" >> $GITHUB_ENV
echo "ESCAPED_REPO=$(echo ${{ github.repository }} | sed 's|\/|\\\/|g')" >> $GITHUB_ENV
git fetch origin
git log $(git branch --show-current)...origin/master --pretty=oneline --format='* %C(auto) %h %s' >> .github/commits_msgs.txt
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.PRERELEASE_VERSION }}
prerelease: true
title: ${{ env.PRERELEASE_VERSION }}
- name: "Updating Release Notes MD File"
continue-on-error: false
run: |
pwd
sed -i '/#### New Features ✅/r .github/commits_msgs.txt' .github/release_notes_template.md
perl -pi -w -e 's/{RELEASE_DATE}/${{ env.RELEASE_DATE }}/g;' -e 's/{RELEASE_TAG}/${{ env.PRERELEASE_VERSION }}/g;' \
-e 's/{GIT_REPO}/${{ env.ESCAPED_REPO }}/g;' .github/release_notes_template.md
- name: "Fetching Release GitHub ID and Updating Local Release Notes"
continue-on-error: true
run: |
curl -o .github/current_release.json --location --request GET https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.PRERELEASE_VERSION }} \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
echo "RELEASE_GIT_ID=$(grep --max-count=1 '"id":.*' .github/current_release.json | sed -n 's/[^0-9]*//gp')" >> $GITHUB_ENV
- name: "Updating Remote Release Notes"
continue-on-error: true
run: |
curl --location --request PATCH https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_GIT_ID }} \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'Content-Type: application/json' \
--data-raw "{\"tag_name\" : \"${{ env.PRERELEASE_VERSION }}\",\"body\": \"$(perl -p -e 's/\n/\\n/' .github/release_notes_template.md)\"}"