feat: test versioning script
This commit is contained in:
parent
1d63d17813
commit
c5dd762580
1 changed files with 13 additions and 9 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
# rm /tmp/ssh_key
|
# rm /tmp/ssh_key
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
name: Deploy eolas-api
|
name: Deploy eolas-api
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -27,7 +28,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Determine version bump
|
- name: Determine version bump and update package.json
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||||
|
|
@ -38,7 +39,7 @@ jobs:
|
||||||
version=${latest_tag#v}
|
version=${latest_tag#v}
|
||||||
IFS='.' read -r major minor patch <<< "$version"
|
IFS='.' read -r major minor patch <<< "$version"
|
||||||
|
|
||||||
if echo "$commit_msg" | grep -q "BREAKING CHANGE:"; then
|
if echo "$commit_msg" | grep -qE "^major(\(.*\))?:|BREAKING CHANGE:"; then
|
||||||
major=$((major + 1))
|
major=$((major + 1))
|
||||||
minor=0
|
minor=0
|
||||||
patch=0
|
patch=0
|
||||||
|
|
@ -59,17 +60,17 @@ jobs:
|
||||||
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
|
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
|
||||||
echo "new_version=$new_version" >> $GITHUB_OUTPUT
|
echo "new_version=$new_version" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update package.json version
|
# Update package.json
|
||||||
|
sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" package.json
|
||||||
|
|
||||||
|
- name: Commit version change
|
||||||
if: steps.version.outputs.new_tag != ''
|
if: steps.version.outputs.new_tag != ''
|
||||||
run: |
|
run: |
|
||||||
# Update version in package.json
|
|
||||||
sed -i "s/\"version\": \".*\"/\"version\": \"${{ steps.version.outputs.new_version }}\"/" package.json
|
|
||||||
|
|
||||||
git config user.name "forgejo-actions[bot]"
|
git config user.name "forgejo-actions[bot]"
|
||||||
git config user.email "forgejo-actions[bot]@noreply"
|
git config user.email "forgejo-actions[bot]@noreply"
|
||||||
git add package.json
|
git add package.json
|
||||||
git commit -m "chore: bump version to ${{ steps.version.outputs.new_tag }}" || true
|
git commit --amend --no-edit
|
||||||
git push origin main || true
|
git push -f origin main
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
if: steps.version.outputs.new_tag != ''
|
if: steps.version.outputs.new_tag != ''
|
||||||
|
|
@ -80,6 +81,9 @@ jobs:
|
||||||
- name: Create Forgejo Release
|
- name: Create Forgejo Release
|
||||||
if: steps.version.outputs.new_tag != ''
|
if: steps.version.outputs.new_tag != ''
|
||||||
run: |
|
run: |
|
||||||
|
# Get the commit message for release body
|
||||||
|
commit_msg=$(git log -1 --pretty=%B | jq -Rs .)
|
||||||
|
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
|
@ -87,7 +91,7 @@ jobs:
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"${{ steps.version.outputs.new_tag }}\",
|
\"tag_name\": \"${{ steps.version.outputs.new_tag }}\",
|
||||||
\"name\": \"${{ steps.version.outputs.new_tag }}\",
|
\"name\": \"${{ steps.version.outputs.new_tag }}\",
|
||||||
\"body\": \"Release ${{ steps.version.outputs.new_tag }}\"
|
\"body\": $commit_msg
|
||||||
}"
|
}"
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue