-
Notifications
You must be signed in to change notification settings - Fork 34
54 lines (54 loc) · 1.93 KB
/
Copy pathupdatePackageVersion.yaml
File metadata and controls
54 lines (54 loc) · 1.93 KB
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
name: Update package version
run-name: ${{ github.actor }} is updating the package version 🚀
on:
push:
tags:
- 'v*.*.*'
jobs:
Update-Package-Version:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Prepare Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git fetch
git checkout master
tag_name=${GITHUB_REF#refs/tags/}
commit_hash=$(git rev-list -n 1 $tag_name)
echo "for tag hash of a commit $commit_hash"
branch_name=$(git branch -r --contains $commit_hash --format="%(refname:short)" | sed 's/^origin\///')
echo "for commit $commit_hash branch name is $branch_name"
git checkout $branch_name
- name: Run Python Script
run: |
python .github/python_scripts/modify_package_version_based_on_git_tag.py
git add .
git status
- name: Commit changes
run: |
if [ -n "$(git status --porcelain)" ]
then
tag_name=${GITHUB_REF#refs/tags/}
git tag -d ${tag_name}
git push origin :${tag_name}
git commit -m "Automated package.json version update for tag ${tag_name}"
git push
head_name=$(git rev-parse HEAD)
git tag -a ${tag_name} ${head_name} -m "Tagging commit ${head_name}"
echo "Tagging commit ${head_name}"
git push origin ${tag_name}
echo "Changes commited and pushed, tag is on $(git rev-list -n 1 ${tag_name})"
else
echo "No changes found"
fi
- run: echo "🍏 This job's status is ${{ job.status }}."