Skip to content

Commit

Permalink
Support full semver versions in release build
Browse files Browse the repository at this point in the history
  • Loading branch information
krypciak committed May 1, 2024
1 parent 887b4d0 commit 3a2f76f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 41 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ on:
workflow_dispatch:
push:
branches:
- main

- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Compile
run: npm install; npm run start
run: pnpm install; pnpm run start
82 changes: 46 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,74 @@ on:
branches:
- main

jobs:
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=${version:1}
echo "VERSION=$version" >> $GITHUB_ENV
echo "VERSION_NUMERIC=$version_numeric" >> $GITHUB_ENV
echo "$VERSION" "$version"
if [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Commit name matches"
else
echo "Commit name doesnt match"
exit 1
fi
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"
- uses: actions/setup-node@v4
- 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
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
git add ./CHANGELOG.md
sed -i "/\[Unreleased\]/a ## [$VERSION_NUMERIC] newDateHere" ./CHANGELOG.md
sed -i "s/newDateHere/$(date '+%Y-%m-%d')/g" ./CHANGELOG.md
git add ./CHANGELOG.md
- 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:main
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:main
- 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
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"
git tag -a "$VERSION" -m "Version $VERSION"
git push origin "$VERSION"
- name: Run pack.sh
run: ./pack.sh
Expand All @@ -71,8 +81,8 @@ jobs:
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
*.ccmod
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
body: ${{ steps.changelog_reader.outputs.changes }}
files: |
*.ccmod
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
body: ${{ steps.changelog_reader.outputs.changes }}

0 comments on commit 3a2f76f

Please sign in to comment.