-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (86 loc) · 3.49 KB
/
main.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
101
102
name: Release pack
on:
push:
branches:
- master
jobs:
release:
if: startsWith(github.event.head_commit.message, 'vv')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install semver
run: |
npm i -g semver
- name: Check commit message
id: check_commit_message
run: |
version=$(git log --format=%B -n 1 ${{ github.sha }})
version=${version:1}
version_numeric="$(semver "${version:1}")"
if [[ $? = 1 ]]; then
echo "Commit name doesnt match"
exit 1
fi
echo "VERSION=$version" >> $GITHUB_ENV
echo "VERSION_NUMERIC=$version_numeric" >> $GITHUB_ENV
echo "$VERSION" "$version"
# Check if the version string contains a hyphen followed by non-empty characters
is_prerealese=false
if [[ $version =~ -([0-9A-Za-z-]+) ]]; then
is_prerealese=true
fi
echo "IS_PREREALESE=$is_prerealese" >> $GITHUB_ENV
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false
- name: Update package.json and ccmod.json
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION_NUMERIC}\"/" package.json ccmod.json
git add package.json ccmod.json
- name: Update CHANGELOG.md
run: |
sed -i "/\[Unreleased\]/a ## [$VERSION_NUMERIC] newDateHere" ./CHANGELOG.md
sed -i "s/newDateHere/$(date '+%Y-%m-%d')/g" ./CHANGELOG.md
if [ $IS_PREREALESE = false ]; then
git add ./CHANGELOG.md
fi
- name: Commit changes
run: |
git config --global user.email "${GITHUB_ACTOR_EMAIL}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global --add safe.directory /github/workspaces
git commit -m "$VERSION"
git push origin HEAD:master
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- name: Create and push a new tag
run: |
git tag -a "$VERSION" -m "Version $VERSION"
git push origin "$VERSION"
- name: Run pack.sh
run: ./pack.sh
- name: Run bundle.sh
run: ./bundle.sh
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
*.ccmod
bundle.zip
prerelease: ${{ env.IS_PREREALESE }}
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
body: ${{ steps.changelog_reader.outputs.changes }}