Skip to content

Commit 74759c9

Browse files
SimYunSupclaude
andauthored
Remove NuGet package version checks (#4)
Co-authored-by: Claude <[email protected]>
1 parent 327ebb4 commit 74759c9

File tree

2 files changed

+141
-76
lines changed

2 files changed

+141
-76
lines changed

.github/workflows/tailwindcss-auto-update.yaml

Lines changed: 117 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
check-and-update:
10+
check-update:
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
14-
packages: write
12+
outputs:
13+
update_needed: ${{ steps.check_update.outputs.update_needed }}
14+
tailwindcss_version: ${{ steps.get_tailwind_version.outputs.tailwindcss_version }}
15+
tailwindcss_version_clean: ${{ steps.get_tailwind_version.outputs.tailwindcss_version_clean }}
16+
current_tailwind_version: ${{ steps.get_nuget_version.outputs.current_tailwind_version }}
17+
current_revision: ${{ steps.get_nuget_version.outputs.current_revision }}
18+
lib_version: ${{ steps.get_nuget_version.outputs.lib_version }}
19+
new_lib_version: ${{ steps.check_update.outputs.new_lib_version }}
20+
new_version: ${{ steps.check_update.outputs.new_version }}
1521

1622
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
21-
22-
- name: Setup .NET SDK
23-
uses: actions/setup-dotnet@v4
24-
with:
25-
dotnet-version: "9.x"
26-
2723
- name: Get latest TailwindCSS version
2824
id: get_tailwind_version
2925
run: |
@@ -34,99 +30,150 @@ jobs:
3430
exit 1
3531
fi
3632
echo "Latest TailwindCSS version: $LATEST_TAILWIND_VERSION"
37-
echo "TAILWINDCSS_VERSION=$LATEST_TAILWIND_VERSION" >> $GITHUB_ENV
38-
echo "TAILWINDCSS_VERSION_CLEAN=${LATEST_TAILWIND_VERSION//v/}" >> $GITHUB_ENV
39-
- name: Get current version from csproj
40-
id: get_current_version
33+
echo "tailwindcss_version=$LATEST_TAILWIND_VERSION" >> $GITHUB_OUTPUT
34+
echo "tailwindcss_version_clean=${LATEST_TAILWIND_VERSION//v/}" >> $GITHUB_OUTPUT
35+
36+
- name: Get current version from NuGet
37+
id: get_nuget_version
4138
run: |
4239
set -e
43-
CURRENT_VERSION=$(grep -oP '<Version>\K[^<]+' ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj)
44-
if [ -z "$CURRENT_VERSION" ]; then
45-
echo "Error: Failed to extract current version from csproj file." >&2
46-
exit 1
47-
fi
48-
echo "Current version: $CURRENT_VERSION"
49-
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
50-
51-
# Extract library version and TailwindCSS version
52-
LIB_VERSION=$(echo $CURRENT_VERSION | cut -d'+' -f1)
53-
CURRENT_TAILWIND_VERSION=$(echo $CURRENT_VERSION | cut -d'+' -f2 | sed 's/v//')
54-
if [ -z "$LIB_VERSION" ] || [ -z "$CURRENT_TAILWIND_VERSION" ]; then
55-
echo "Error: Malformed version string in csproj file." >&2
56-
exit 1
40+
PACKAGE_NAME="DotnetDevKR.TailwindCSS"
41+
42+
# Fetch all versions from NuGet API
43+
NUGET_RESPONSE=$(curl -s "https://api.nuget.org/v3-flatcontainer/${PACKAGE_NAME,,}/index.json")
44+
45+
if echo "$NUGET_RESPONSE" | grep -q '"versions"'; then
46+
# Get the latest version from NuGet (supports both 3-part and 4-part versions)
47+
# Version format: {TailwindMajor}.{TailwindMinor}.{TailwindPatch}.{Revision}
48+
LIB_VERSION=$(echo "$NUGET_RESPONSE" | grep -oP '"\d+\.\d+\.\d+(\.\d+)?' | tail -1 | tr -d '"')
49+
50+
if [ -z "$LIB_VERSION" ]; then
51+
echo "No version found in NuGet. Using default."
52+
LIB_VERSION="0.0.0.0"
53+
CURRENT_TAILWIND_VERSION="0.0.0"
54+
CURRENT_REVISION="0"
55+
else
56+
echo "Latest NuGet library version: $LIB_VERSION"
57+
58+
# Parse version: could be 3-part (old) or 4-part (new format)
59+
IFS='.' read -ra VERSION_PARTS <<< "$LIB_VERSION"
60+
if [ ${#VERSION_PARTS[@]} -eq 4 ]; then
61+
# New format: TailwindMajor.TailwindMinor.TailwindPatch.Revision
62+
CURRENT_TAILWIND_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
63+
CURRENT_REVISION="${VERSION_PARTS[3]}"
64+
else
65+
# Old format: need to fetch from nuspec
66+
NUSPEC_URL="https://api.nuget.org/v3-flatcontainer/${PACKAGE_NAME,,}/${LIB_VERSION}/${PACKAGE_NAME,,}.nuspec"
67+
echo "Fetching nuspec from: $NUSPEC_URL"
68+
NUSPEC_RESPONSE=$(curl -s "$NUSPEC_URL")
69+
70+
CURRENT_TAILWIND_VERSION=$(echo "$NUSPEC_RESPONSE" | grep -oP 'TailwindCSS[^0-9]*v?\K\d+\.\d+\.\d+' | head -1)
71+
if [ -z "$CURRENT_TAILWIND_VERSION" ]; then
72+
FULL_VERSION=$(echo "$NUSPEC_RESPONSE" | grep -oP '<version>\K[^<]+')
73+
if echo "$FULL_VERSION" | grep -q '+v'; then
74+
CURRENT_TAILWIND_VERSION=$(echo "$FULL_VERSION" | cut -d'+' -f2 | sed 's/v//')
75+
else
76+
CURRENT_TAILWIND_VERSION="0.0.0"
77+
fi
78+
fi
79+
CURRENT_REVISION="0"
80+
fi
81+
fi
82+
83+
echo "lib_version=$LIB_VERSION" >> $GITHUB_OUTPUT
84+
echo "Current TailwindCSS version: $CURRENT_TAILWIND_VERSION"
85+
echo "Current revision: $CURRENT_REVISION"
86+
echo "current_tailwind_version=$CURRENT_TAILWIND_VERSION" >> $GITHUB_OUTPUT
87+
echo "current_revision=$CURRENT_REVISION" >> $GITHUB_OUTPUT
88+
else
89+
echo "Package not found on NuGet. This might be the first publish."
90+
echo "lib_version=0.0.0.0" >> $GITHUB_OUTPUT
91+
echo "current_tailwind_version=0.0.0" >> $GITHUB_OUTPUT
92+
echo "current_revision=0" >> $GITHUB_OUTPUT
5793
fi
5894
59-
echo "Current library version: $LIB_VERSION"
60-
echo "Current TailwindCSS version: $CURRENT_TAILWIND_VERSION"
61-
echo "LIB_VERSION=$LIB_VERSION" >> $GITHUB_ENV
62-
echo "CURRENT_TAILWIND_VERSION=$CURRENT_TAILWIND_VERSION" >> $GITHUB_ENV
63-
6495
- name: Check if update is needed
6596
id: check_update
6697
run: |
98+
CURRENT_TAILWIND_VERSION="${{ steps.get_nuget_version.outputs.current_tailwind_version }}"
99+
TAILWINDCSS_VERSION_CLEAN="${{ steps.get_tailwind_version.outputs.tailwindcss_version_clean }}"
100+
CURRENT_REVISION="${{ steps.get_nuget_version.outputs.current_revision }}"
101+
67102
if [ "$CURRENT_TAILWIND_VERSION" != "$TAILWINDCSS_VERSION_CLEAN" ]; then
68103
echo "Update needed: $CURRENT_TAILWIND_VERSION -> $TAILWINDCSS_VERSION_CLEAN"
69-
echo "UPDATE_NEEDED=true" >> $GITHUB_ENV
104+
echo "update_needed=true" >> $GITHUB_OUTPUT
70105
71-
# Increment patch version (0.1.0 -> 0.1.1)
72-
IFS='.' read -ra VERSION_PARTS <<< "$LIB_VERSION"
73-
MAJOR=${VERSION_PARTS[0]}
74-
MINOR=${VERSION_PARTS[1]}
75-
PATCH=${VERSION_PARTS[2]}
76-
# NEW_PATCH=$((PATCH + 1))
77-
NEW_PATCH=$((PATCH))
78-
NEW_LIB_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
106+
# New TailwindCSS version, reset revision to 0
107+
# Version format: {TailwindMajor}.{TailwindMinor}.{TailwindPatch}.{Revision}
108+
NEW_REVISION="0"
109+
NEW_LIB_VERSION="$TAILWINDCSS_VERSION_CLEAN.$NEW_REVISION"
79110
80111
echo "New library version: $NEW_LIB_VERSION"
81-
echo "NEW_LIB_VERSION=$NEW_LIB_VERSION" >> $GITHUB_ENV
82-
echo "NEW_VERSION=$NEW_LIB_VERSION+v$TAILWINDCSS_VERSION_CLEAN" >> $GITHUB_ENV
112+
echo "new_lib_version=$NEW_LIB_VERSION" >> $GITHUB_OUTPUT
113+
echo "new_version=$NEW_LIB_VERSION" >> $GITHUB_OUTPUT
83114
else
84115
echo "No update needed. Current version is already up to date."
85-
echo "UPDATE_NEEDED=false" >> $GITHUB_ENV
116+
echo "update_needed=false" >> $GITHUB_OUTPUT
86117
fi
87118
119+
build-and-publish:
120+
needs: check-update
121+
if: needs.check-update.outputs.update_needed == 'true'
122+
runs-on: ubuntu-latest
123+
permissions:
124+
contents: write
125+
packages: write
126+
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 0
132+
133+
- name: Setup .NET SDK
134+
uses: actions/setup-dotnet@v4
135+
with:
136+
dotnet-version: "9.x"
137+
88138
- name: Update version in csproj
89-
if: env.UPDATE_NEEDED == 'true'
90139
run: |
91-
sed -i "s|<Version>.*</Version>|<Version>${NEW_VERSION}</Version>|" ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj
92-
echo "Updated csproj to version: $NEW_VERSION"
140+
sed -i "s|<Version>.*</Version>|<Version>${{ needs.check-update.outputs.new_version }}</Version>|" ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj
141+
echo "Updated csproj to version: ${{ needs.check-update.outputs.new_version }}"
93142
94143
- name: Update version in install.sh
95-
if: env.UPDATE_NEEDED == 'true'
96144
run: |
97-
sed -i "s|VERSION=\${1:-\"v[^\"]*\"}|VERSION=\${1:-\"${TAILWINDCSS_VERSION}\"}|" ./DotnetDevKR.TailwindCSS/runtime/install.sh
98-
echo "Updated install.sh to TailwindCSS version: $TAILWINDCSS_VERSION"
145+
sed -i "s|VERSION=\${1:-\"v[^\"]*\"}|VERSION=\${1:-\"${{ needs.check-update.outputs.tailwindcss_version }}\"}|" ./DotnetDevKR.TailwindCSS/runtime/install.sh
146+
echo "Updated install.sh to TailwindCSS version: ${{ needs.check-update.outputs.tailwindcss_version }}"
99147
100148
- name: Download TailwindCSS executables
101-
if: env.UPDATE_NEEDED == 'true'
102149
run: |
103150
chmod +x ./DotnetDevKR.TailwindCSS/runtime/install.sh
104-
./DotnetDevKR.TailwindCSS/runtime/install.sh ${{ env.TAILWINDCSS_VERSION }}
151+
./DotnetDevKR.TailwindCSS/runtime/install.sh ${{ needs.check-update.outputs.tailwindcss_version }}
105152
106153
- name: Restore dependencies
107-
if: env.UPDATE_NEEDED == 'true'
108154
run: dotnet restore DotnetDevKR.TailwindCSS.sln
109155

110156
- name: Build
111-
if: env.UPDATE_NEEDED == 'true'
112157
run: dotnet build DotnetDevKR.TailwindCSS.sln --configuration Release --no-restore
113158

114159
- name: Pack
115-
if: env.UPDATE_NEEDED == 'true'
116160
run: |
117161
dotnet pack ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj --configuration Release \
118162
--no-build --no-restore \
119163
--output ./artifacts \
120-
/p:Version=${{ env.NEW_VERSION }}
164+
/p:Version=${{ needs.check-update.outputs.new_version }}
121165
122-
- name: Push changes and tags
123-
if: env.UPDATE_NEEDED == 'true'
166+
- name: Commit and push changes
124167
run: |
168+
git config user.name "github-actions[bot]"
169+
git config user.email "github-actions[bot]@users.noreply.github.com"
170+
git add -A
171+
git commit -m "chore: Update TailwindCSS to ${{ needs.check-update.outputs.tailwindcss_version }} and bump version to ${{ needs.check-update.outputs.new_version }}"
172+
git tag "v${{ needs.check-update.outputs.new_lib_version }}"
125173
git push origin ${{ github.ref_name }}
126-
git push origin "v${{ env.NEW_LIB_VERSION }}"
174+
git push origin "v${{ needs.check-update.outputs.new_lib_version }}"
127175
128176
- name: Publish to NuGet.org
129-
if: env.UPDATE_NEEDED == 'true'
130177
run: |
131178
dotnet nuget push ./artifacts/*.nupkg \
132179
--source https://api.nuget.org/v3/index.json \
@@ -136,7 +183,6 @@ jobs:
136183
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
137184

138185
- name: Publish to GitHub Packages
139-
if: env.UPDATE_NEEDED == 'true'
140186
run: |
141187
dotnet nuget push ./artifacts/*.nupkg \
142188
--source https://nuget.pkg.github.com/dotnetdev-kr/index.json \
@@ -146,23 +192,21 @@ jobs:
146192
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147193

148194
- name: Create GitHub Release
149-
if: env.UPDATE_NEEDED == 'true'
150195
uses: softprops/action-gh-release@v1
151196
with:
152-
tag_name: v${{ env.NEW_LIB_VERSION }}
153-
name: Release v${{ env.NEW_LIB_VERSION }}
197+
tag_name: v${{ needs.check-update.outputs.new_lib_version }}
198+
name: Release v${{ needs.check-update.outputs.new_lib_version }}
154199
body: |
155200
## Updates
156-
- Updated TailwindCSS from v${{ env.CURRENT_TAILWIND_VERSION }} to ${{ env.TAILWINDCSS_VERSION }}
157-
- Package version: ${{ env.NEW_VERSION }}
201+
- Updated TailwindCSS from v${{ needs.check-update.outputs.current_tailwind_version }} to ${{ needs.check-update.outputs.tailwindcss_version }}
202+
- Package version: ${{ needs.check-update.outputs.new_version }}
158203
159204
## Installation
160205
```bash
161-
dotnet add package DotnetDevKR.TailwindCSS --version ${{ env.NEW_VERSION }}
206+
dotnet add package DotnetDevKR.TailwindCSS --version ${{ needs.check-update.outputs.new_version }}
162207
```
163208
files: ./artifacts/*.nupkg
164209
draft: false
165210
prerelease: false
166211
env:
167212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168-

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,39 @@ Check out the `DotnetDevKR.TailwindCSS.WebTest` folder for a complete Blazor Web
128128
3. **TailwindCSS Execution**: Runs the appropriate TailwindCSS standalone executable
129129
4. **File Processing**: Compiles your input CSS file and outputs the result
130130

131+
## Versioning
132+
133+
This package follows a 4-part version scheme that directly maps to TailwindCSS versions:
134+
135+
```
136+
{TailwindMajor}.{TailwindMinor}.{TailwindPatch}.{Revision}
137+
```
138+
139+
### Examples
140+
141+
| Package Version | TailwindCSS Version | Revision |
142+
| --------------- | ------------------- | -------- |
143+
| `4.1.17.0` | v4.1.17 | 0 |
144+
| `4.1.17.1` | v4.1.17 | 1 |
145+
| `4.2.0.0` | v4.2.0 | 0 |
146+
147+
- **First 3 parts**: Directly correspond to the TailwindCSS version
148+
- **4th part (Revision)**: Increments for package-only fixes (without TailwindCSS version change)
149+
150+
This versioning makes it easy to identify which TailwindCSS version is included in the package at a glance.
151+
131152
## Automatic TailwindCSS Version Updates
132153

133154
This package automatically stays up-to-date with the latest TailwindCSS releases:
134155

135156
- 🤖 **Automated Checks**: Daily automated checks for new TailwindCSS versions
136157
- 📦 **Auto-Publishing**: Automatically builds and publishes updated NuGet packages
137-
- 🏷️ **Version Format**: `{library-version}+v{tailwindcss-version}` (e.g., `0.1.0+v4.1.11`)
158+
- 🏷️ **Version Format**: `{TailwindMajor}.{TailwindMinor}.{TailwindPatch}.{Revision}` (e.g., `4.1.17.0`)
138159
- 🔄 **Seamless Updates**: Simply update the NuGet package to get the latest TailwindCSS features
139160

140161
When a new TailwindCSS version is released, our GitHub Actions workflow:
141-
1. Detects the new version
142-
2. Updates the package version (increments patch version)
162+
1. Detects the new version from NuGet registry
163+
2. Creates a new package version (e.g., `4.1.18.0`)
143164
3. Downloads the latest TailwindCSS executables
144165
4. Builds and publishes to NuGet.org
145166
5. Creates a GitHub release with release notes

0 commit comments

Comments
 (0)