Skip to content

Commit 60a1ae6

Browse files
authored
Merge pull request #2 from dotnetdev-kr/claude/tailwind-auto-nuget-publish-011CUpHbStvK5RzNRBidbVBr
2 parents 7d0800f + 76e1642 commit 60a1ae6

File tree

4 files changed

+235
-4
lines changed

4 files changed

+235
-4
lines changed

.github/workflows/nuget-release.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ on:
99
jobs:
1010
publish:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
1215
steps:
1316
- name: Checkout repository
14-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1518

1619
- name: Setup .NET SDK
17-
uses: actions/setup-dotnet@v3
20+
uses: actions/setup-dotnet@v4
1821
with:
1922
dotnet-version: "9.x"
2023

@@ -55,10 +58,20 @@ jobs:
5558
--output ./artifacts \
5659
/p:Version=${{ env.VERSION }}
5760
58-
- name: Publish to NuGet
61+
- name: Publish to NuGet.org
5962
run: |
6063
dotnet nuget push ./artifacts/*.nupkg \
6164
--source https://api.nuget.org/v3/index.json \
62-
--api-key ${{ secrets.NUGET_API_KEY }}
65+
--api-key ${{ secrets.NUGET_API_KEY }} \
66+
--skip-duplicate
6367
env:
6468
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
69+
70+
- name: Publish to GitHub Packages
71+
run: |
72+
dotnet nuget push ./artifacts/*.nupkg \
73+
--source https://nuget.pkg.github.com/dotnetdev-kr/index.json \
74+
--api-key ${{ secrets.GITHUB_TOKEN }} \
75+
--skip-duplicate
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Auto Update TailwindCSS Version
2+
3+
on:
4+
schedule:
5+
# Run every day at 00:00 UTC
6+
- cron: '0 0 * * *'
7+
workflow_dispatch:
8+
9+
jobs:
10+
check-and-update:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
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+
27+
- name: Get latest TailwindCSS version
28+
id: get_tailwind_version
29+
run: |
30+
set -e
31+
LATEST_TAILWIND_VERSION=$(curl -s https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
32+
if [ -z "$LATEST_TAILWIND_VERSION" ]; then
33+
echo "Error: Failed to fetch latest TailwindCSS version from GitHub API." >&2
34+
exit 1
35+
fi
36+
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
41+
run: |
42+
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
57+
fi
58+
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+
64+
- name: Check if update is needed
65+
id: check_update
66+
run: |
67+
if [ "$CURRENT_TAILWIND_VERSION" != "$TAILWINDCSS_VERSION_CLEAN" ]; then
68+
echo "Update needed: $CURRENT_TAILWIND_VERSION -> $TAILWINDCSS_VERSION_CLEAN"
69+
echo "UPDATE_NEEDED=true" >> $GITHUB_ENV
70+
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_LIB_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
78+
79+
echo "New library version: $NEW_LIB_VERSION"
80+
echo "NEW_LIB_VERSION=$NEW_LIB_VERSION" >> $GITHUB_ENV
81+
echo "NEW_VERSION=$NEW_LIB_VERSION+v$TAILWINDCSS_VERSION_CLEAN" >> $GITHUB_ENV
82+
else
83+
echo "No update needed. Current version is already up to date."
84+
echo "UPDATE_NEEDED=false" >> $GITHUB_ENV
85+
fi
86+
87+
- name: Update version in csproj
88+
if: env.UPDATE_NEEDED == 'true'
89+
run: |
90+
sed -i "s|<Version>.*</Version>|<Version>${NEW_VERSION}</Version>|" ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj
91+
echo "Updated csproj to version: $NEW_VERSION"
92+
93+
- name: Update version in install.sh
94+
if: env.UPDATE_NEEDED == 'true'
95+
run: |
96+
sed -i "s|VERSION=\${1:-\"v[^\"]*\"}|VERSION=\${1:-\"${TAILWINDCSS_VERSION}\"}|" ./DotnetDevKR.TailwindCSS/runtime/install.sh
97+
echo "Updated install.sh to TailwindCSS version: $TAILWINDCSS_VERSION"
98+
99+
- name: Download TailwindCSS executables
100+
if: env.UPDATE_NEEDED == 'true'
101+
run: |
102+
chmod +x ./DotnetDevKR.TailwindCSS/runtime/install.sh
103+
./DotnetDevKR.TailwindCSS/runtime/install.sh ${{ env.TAILWINDCSS_VERSION }}
104+
105+
- name: Commit changes
106+
if: env.UPDATE_NEEDED == 'true'
107+
run: |
108+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
109+
git config --local user.name "github-actions[bot]"
110+
git add ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj
111+
git add ./DotnetDevKR.TailwindCSS/runtime/install.sh
112+
git add ./DotnetDevKR.TailwindCSS/runtime/tailwindcss-*
113+
git commit -m "chore: Update TailwindCSS to ${{ env.TAILWINDCSS_VERSION }} and bump version to ${{ env.NEW_VERSION }}"
114+
git tag "v${{ env.NEW_LIB_VERSION }}"
115+
116+
- name: Push changes and tags
117+
if: env.UPDATE_NEEDED == 'true'
118+
run: |
119+
git push origin ${{ github.ref_name }}
120+
git push origin "v${{ env.NEW_LIB_VERSION }}"
121+
122+
- name: Restore dependencies
123+
if: env.UPDATE_NEEDED == 'true'
124+
run: dotnet restore DotnetDevKR.TailwindCSS.sln
125+
126+
- name: Build
127+
if: env.UPDATE_NEEDED == 'true'
128+
run: dotnet build DotnetDevKR.TailwindCSS.sln --configuration Release --no-restore
129+
130+
- name: Pack
131+
if: env.UPDATE_NEEDED == 'true'
132+
run: |
133+
dotnet pack ./DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj --configuration Release \
134+
--no-build --no-restore \
135+
--output ./artifacts \
136+
/p:Version=${{ env.NEW_VERSION }}
137+
138+
- name: Publish to NuGet.org
139+
if: env.UPDATE_NEEDED == 'true'
140+
run: |
141+
dotnet nuget push ./artifacts/*.nupkg \
142+
--source https://api.nuget.org/v3/index.json \
143+
--api-key ${{ secrets.NUGET_API_KEY }} \
144+
--skip-duplicate
145+
env:
146+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
147+
148+
- name: Publish to GitHub Packages
149+
if: env.UPDATE_NEEDED == 'true'
150+
run: |
151+
dotnet nuget push ./artifacts/*.nupkg \
152+
--source https://nuget.pkg.github.com/dotnetdev-kr/index.json \
153+
--api-key ${{ secrets.GITHUB_TOKEN }} \
154+
--skip-duplicate
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
158+
- name: Create GitHub Release
159+
if: env.UPDATE_NEEDED == 'true'
160+
uses: softprops/action-gh-release@v1
161+
with:
162+
tag_name: v${{ env.NEW_LIB_VERSION }}
163+
name: Release v${{ env.NEW_LIB_VERSION }}
164+
body: |
165+
## Updates
166+
- Updated TailwindCSS from v${{ env.CURRENT_TAILWIND_VERSION }} to ${{ env.TAILWINDCSS_VERSION }}
167+
- Package version: ${{ env.NEW_VERSION }}
168+
169+
## Installation
170+
```bash
171+
dotnet add package DotnetDevKR.TailwindCSS --version ${{ env.NEW_VERSION }}
172+
```
173+
files: ./artifacts/*.nupkg
174+
draft: false
175+
prerelease: false
176+
env:
177+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

DotnetDevKR.TailwindCSS/DotnetDevKR.TailwindCSS.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<PackageId>DotnetDevKR.TailwindCSS</PackageId>
77
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
8+
<PackageReadmeFile>README.md</PackageReadmeFile>
89
<RepositoryType>git</RepositoryType>
10+
<RepositoryUrl>https://github.com/dotnetdev-kr/DotnetDevKR.TailwindCSS</RepositoryUrl>
911
<Version>0.0.1+v4.1.11</Version>
1012
<Authors>DotnetDevKR</Authors>
1113
<PackageTags>TailwindCSS</PackageTags>
@@ -20,5 +22,6 @@
2022
<TfmSpecificPackageFile Include="$(OutputPath)DotnetDevKR.TailwindCSS.Compile.dll" PackagePath="lib\$(TargetFramework)" />
2123
<Content Include="build\**" PackagePath="build" />
2224
<None Include="runtime\**\*" Pack="true" PackagePath="build/runtime" />
25+
<None Include="..\README.md" Pack="true" PackagePath="\" />
2326
</ItemGroup>
2427
</Project>

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,34 @@ A .NET MSBuild integration package for TailwindCSS that automatically compiles y
1313

1414
## Installation
1515

16+
### From NuGet.org
17+
1618
Install the NuGet package in your .NET project:
1719

1820
```bash
1921
dotnet add package DotnetDevKR.TailwindCSS
2022
```
2123

24+
### From GitHub Packages
25+
26+
You can also install the package from GitHub Packages:
27+
28+
1. Add GitHub Packages as a NuGet source (one time setup):
29+
```bash
30+
dotnet nuget add source https://nuget.pkg.github.com/dotnetdev-kr/index.json \
31+
--name github \
32+
--username YOUR_GITHUB_USERNAME \
33+
--password YOUR_GITHUB_PAT \
34+
--store-password-in-clear-text
35+
```
36+
37+
2. Install the package:
38+
```bash
39+
dotnet add package DotnetDevKR.TailwindCSS
40+
```
41+
42+
> **Note:** You need a GitHub Personal Access Token (PAT) with `read:packages` scope to install from GitHub Packages.
43+
2244
## Quick Start
2345

2446
> [!Warning]
@@ -106,6 +128,22 @@ Check out the `DotnetDevKR.TailwindCSS.WebTest` folder for a complete Blazor Web
106128
3. **TailwindCSS Execution**: Runs the appropriate TailwindCSS standalone executable
107129
4. **File Processing**: Compiles your input CSS file and outputs the result
108130

131+
## Automatic TailwindCSS Version Updates
132+
133+
This package automatically stays up-to-date with the latest TailwindCSS releases:
134+
135+
- 🤖 **Automated Checks**: Daily automated checks for new TailwindCSS versions
136+
- 📦 **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`)
138+
- 🔄 **Seamless Updates**: Simply update the NuGet package to get the latest TailwindCSS features
139+
140+
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)
143+
3. Downloads the latest TailwindCSS executables
144+
4. Builds and publishes to NuGet.org
145+
5. Creates a GitHub release with release notes
146+
109147
## Requirements
110148

111149
- .NET 6.0 or higher

0 commit comments

Comments
 (0)