-
Notifications
You must be signed in to change notification settings - Fork 204
100 lines (86 loc) · 3.48 KB
/
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Changelog
on:
workflow_dispatch:
inputs:
old_version:
description: "Specify the old version (e.g. v8.0.0)"
new_version:
description: "Specify the new version (e.g. v9.0.0)"
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: Get versions
run: |
old_version=${{ github.event.inputs.old_version }}
new_version=${{ github.event.inputs.new_version }}
new_major_version=$(echo $new_version | cut -d '.' -f 1)
branch_name=actions/changelog-version-${new_major_version}
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
echo "NEW_MAJOR_VERSION=$new_major_version" >> $GITHUB_ENV
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Checkout main
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
ref: main
- name: Set Git Config
run: |
git config --global user.name "stride-dev"
git config --global user.email "dev@stridelabs.com"
- name: Create branch
run: git checkout -b ${{ env.branch_name }}
- name: Fetch main
run: git fetch origin main:main
- name: Update changelogs
run: ./scripts/changelog.sh
- name: Commit changes
run: |
git add .
git commit -m 'updated changelog'
- name: Push changes
id: push
continue-on-error: true
run: |
git push https://$GH_TOKEN@github.com/Stride-Labs/stride.git ${{ env.branch_name }}
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_PAT }}
- name: Check Push Success
if: ${{ steps.push.outcome == 'failure' }}
run: |
echo "Push failed. The token might be expired or have insufficient permissions. Please check your token."
echo "The token can be found in the 'dev-stride' account. To view the token, login to 'dev-stride' and go to:"
echo " -> Profile"
echo " -> Settings"
echo " -> Developer Settings"
echo " -> Personal Access Tokens"
echo " -> Tokens (classic)"
echo " -> 'GH Actions' Token"
echo ""
echo "If the token is expired, you can click on the token and then select 'Regenerate Token'"
echo "After regenerating a new token, you'll have to update the 'GH_ACTIONS_PAT' environment variable:"
echo " -> Navigate to the stride repo"
echo " -> Settings"
echo " -> Secrets and variables"
echo " -> Actions"
echo " -> Then modify 'GH_ACTIONS_PAT'"
exit 1
- name: Fetch New Branch
run: |
git fetch --all
- name: Create Pull Request
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GH_ACTIONS_PAT }}" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title":"${{ env.NEW_MAJOR_VERSION }} Changelog",
"head":"${{ env.branch_name }}",
"base":"main",
"body":"This is an automatically generated pull request.\n\nPlease review and merge the changes.\n\n## Context\n\nUpdated changelog for ${{ env.NEW_MAJOR_VERSION }} release\n\n## Brief Changelog\n\n* Updated main changelog with on-chain and off-chain changes\n",
"maintainer_can_modify": true
}'