Skip to content

Commit 5c833b7

Browse files
committed
Automate GitHub releases and update README.md
1 parent 1eb3397 commit 5c833b7

File tree

2 files changed

+70
-9
lines changed

2 files changed

+70
-9
lines changed

.github/workflows/auto-release.yml

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Auto Build TailwindCSS Image
1+
name: Auto Release
22

33
on:
44
schedule:
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
permissions:
13-
contents: read
13+
contents: write
1414
packages: write
1515
attestations: write
1616
id-token: write
@@ -26,6 +26,8 @@ jobs:
2626

2727
- name: Check out code
2828
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # fetch all tags for release checking
2931

3032
- name: Login to GHCR
3133
uses: docker/login-action@v3
@@ -40,17 +42,32 @@ jobs:
4042
with:
4143
repository: tailwindlabs/tailwindcss
4244

43-
- name: Strip leading “v” from version
45+
- name: Strip leading "v" from version
4446
id: strip-v
4547
run: |
4648
# grab the raw output (e.g. "v4.1.7")
4749
vtag="${{ steps.get-latest-release.outputs.release }}"
48-
# remove one leading “v”
50+
# remove one leading "v"
4951
clean_vtag="${vtag#v}"
5052
# expose it as an output
5153
echo "version_no_v=${clean_vtag}" >> $GITHUB_OUTPUT
54+
echo "full_version=${vtag}" >> $GITHUB_OUTPUT
55+
56+
- name: Check if release already exists
57+
id: check-release
58+
run: |
59+
# Check if we already have a release for this version
60+
version="${{ steps.strip-v.outputs.full_version }}"
61+
if git tag -l | grep -q "^${version}$"; then
62+
echo "exists=true" >> $GITHUB_OUTPUT
63+
echo "Release ${version} already exists, skipping build"
64+
else
65+
echo "exists=false" >> $GITHUB_OUTPUT
66+
echo "Release ${version} does not exist, will build and create"
67+
fi
5268
5369
- name: Build & push multi-arch
70+
if: steps.check-release.outputs.exists == 'false' # Only build if new version
5471
uses: docker/build-push-action@v4
5572
with:
5673
context: .
@@ -62,3 +79,49 @@ jobs:
6279
ghcr.io/scriptogre/tailwindcss:${{ steps.strip-v.outputs.version_no_v }}
6380
build-args: |
6481
TAILWINDCSS_VERSION=${{ steps.strip-v.outputs.version_no_v }}
82+
83+
- name: Create and push tag
84+
if: steps.check-release.outputs.exists == 'false'
85+
run: |
86+
version="${{ steps.strip-v.outputs.full_version }}"
87+
git config user.name "github-actions[bot]"
88+
git config user.email "github-actions[bot]@users.noreply.github.com"
89+
git tag -a "${version}" -m "Auto-release for TailwindCSS ${version}"
90+
git push origin "${version}"
91+
92+
- name: Create GitHub Release
93+
if: steps.check-release.outputs.exists == 'false'
94+
uses: softprops/action-gh-release@v1
95+
with:
96+
tag_name: ${{ steps.strip-v.outputs.full_version }}
97+
name: ${{ steps.strip-v.outputs.full_version }}
98+
body: |
99+
Automatic release for TailwindCSS ${{ steps.strip-v.outputs.full_version }}
100+
101+
1. Create `input.css` in your project:
102+
```css
103+
@import 'tailwindcss';
104+
```
105+
106+
2. Create `docker-compose.yml` in your project:
107+
```yaml
108+
services:
109+
tailwindcss:
110+
image: ghcr.io/scriptogre/tailwindcss:${{ steps.strip-v.outputs.version_no_v }}
111+
tty: true # Required for watch mode
112+
volumes:
113+
- .:/app
114+
command: -i ./input.css -o ./output.css --watch
115+
```
116+
117+
3. Or run `docker run` command (note the `-t` flag is required for watch mode):
118+
```bash
119+
docker run -t -v "$(pwd)":/app \
120+
ghcr.io/scriptogre/tailwindcss:${{ steps.strip-v.outputs.version_no_v }} -i ./input.css -o ./output.css --watch
121+
```
122+
123+
Container available at [ghcr.io/scriptogre/tailwindcss:${{ steps.strip-v.outputs.version_no_v }}](https://ghcr.io/scriptogre/tailwindcss:${{ steps.strip-v.outputs.version_no_v }})
124+
draft: false
125+
prerelease: false
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ No more **Node.JS**. No more **manual downloads of the CLI**.
2020
command: -i ./input.css -o ./output.css --watch
2121
```
2222

23-
3. Or run `docker run` command (note the `-t` flag is required for watch mode):
23+
3. Or run `docker run` command (note the `-t` flag is required for watch mode):
2424
```bash
25-
docker run -t \
26-
-v "$(pwd)":/app \
27-
ghcr.io/scriptogre/tailwindcss:latest \
28-
-i ./input.css -o ./output.css --watch
25+
docker run -t -v "$(pwd)":/app \
26+
ghcr.io/scriptogre/tailwindcss:latest -i ./input.css -o ./output.css --watch
2927
```
3028

3129
### **Watch Mode Requirement**

0 commit comments

Comments
 (0)