5
5
- main
6
6
- development
7
7
permissions :
8
- contents : write
9
- actions : read
8
+ contents : write
9
+ actions : read
10
10
jobs :
11
11
check-commit :
12
12
runs-on : ubuntu-latest
@@ -37,19 +37,16 @@ jobs:
37
37
if : needs.check-commit.outputs.should_release == 'true'
38
38
runs-on : macos-latest
39
39
steps :
40
- # Checkout the repository with full commit history
41
40
- name : Checkout code
42
41
uses : actions/checkout@v4
43
42
with :
44
- fetch-depth : 0
43
+ fetch-depth : 0 # Full history needed for tag inspection
45
44
46
- # Set up Swift environment
47
45
- name : Setup Swift
48
46
uses : swift-actions/setup-swift@v2
49
47
with :
50
48
swift-version : " 6.1"
51
49
52
- # Cache SwiftPM dependencies
53
50
- name : Cache SwiftPM dependencies
54
51
uses : actions/cache@v3
55
52
with :
@@ -58,31 +55,32 @@ jobs:
58
55
restore-keys : |
59
56
${{ runner.os }}-swiftpm-
60
57
61
- # Resolve Swift package dependencies
62
58
- name : Resolve dependencies
63
59
run : swift package resolve
64
60
65
- # Run tests to validate the package
66
61
- name : Run tests
67
62
run : swift test
68
63
continue-on-error : false
69
64
70
- # Install GitHub CLI for release creation
71
65
- name : Setup GitHub CLI
72
66
run : |
73
67
brew install gh
74
68
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
75
69
76
- # Bump version, create tag, and release
77
70
- name : Bump version and create release
78
71
env :
79
72
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
73
run : |
81
74
#!/bin/bash
82
75
set -e
83
76
84
- # Get the current version from VERSION file (default to 0.0.0 if not exists)
85
- CURRENT_VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
77
+ # Get the latest version tag (default to 0.0.0 if no tags exist)
78
+ LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
79
+ if [ -z "$LATEST_TAG" ]; then
80
+ CURRENT_VERSION="0.0.0"
81
+ else
82
+ CURRENT_VERSION="${LATEST_TAG#v}" # Remove 'v' prefix (e.g., v0.0.0 -> 0.0.0)
83
+ fi
86
84
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
87
85
88
86
# Get the latest commit message
@@ -110,14 +108,9 @@ jobs:
110
108
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
111
109
echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION"
112
110
113
- # Update VERSION file
114
- echo "$NEW_VERSION" > VERSION
115
-
116
- # Commit version changes
111
+ # Configure git
117
112
git config user.name "GitHub Actions"
118
113
git config user.email "actions@github.com"
119
- git add VERSION
120
- git commit -m "chore(release): bump version to $NEW_VERSION [skip ci]" || echo "No changes to commit"
121
114
122
115
# Configure git to use GitHub token
123
116
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/maclong9/web-ui.git
@@ -136,10 +129,6 @@ jobs:
136
129
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
137
130
git push origin "v$NEW_VERSION"
138
131
139
- # Create and push tag
140
- git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
141
- git push origin "v$NEW_VERSION"
142
-
143
132
# Generate release notes from commit message
144
133
RELEASE_NOTES="Automated release for v$NEW_VERSION\n\nChanges:\n- $COMMIT_MESSAGE"
145
134
0 commit comments