-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (132 loc) · 5.13 KB
/
release.yml
File metadata and controls
146 lines (132 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Build & Release
on:
push:
branches: [master]
permissions:
contents: write
packages: write
env:
IMAGE_NAME: ghcr.io/ohmzi/tday
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=v${VERSION}" >> "$GITHUB_OUTPUT"
PREVIOUS=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "previous=$PREVIOUS" >> "$GITHUB_OUTPUT"
# ────────────────────────────────────────────
# Docker Image
# ────────────────────────────────────────────
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
labels: |
org.opencontainers.image.source=https://github.com/ohmzi/Tday
org.opencontainers.image.description=Tday - Personal task planner
build-args: |
DATABASE_URL=postgresql://dummy:dummy@localhost:5432/dummy
cache-from: type=gha
cache-to: type=gha,mode=max
# ────────────────────────────────────────────
# Tag & Release
# ────────────────────────────────────────────
- name: Create tag
run: |
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
- name: Generate release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
PREVIOUS: ${{ steps.version.outputs.previous }}
run: |
# Auto-generate changelog from merged PRs
GENERATED=""
if [ -n "$PREVIOUS" ]; then
GENERATED=$(gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="$VERSION" \
-f previous_tag_name="$PREVIOUS" \
--jq '.body' 2>/dev/null) || GENERATED=""
fi
if [ -z "$GENERATED" ]; then
GENERATED=$(git log --merges --pretty=format:"* %s by @${{ github.actor }} in https://github.com/${{ github.repository }}" ${PREVIOUS:+$PREVIOUS..HEAD} HEAD 2>/dev/null)
if [ -z "$GENERATED" ]; then
GENERATED=$(git log --oneline --pretty=format:"* %s by @${{ github.actor }}" ${PREVIOUS:+$PREVIOUS..HEAD} -20 2>/dev/null)
fi
fi
if [ -z "$GENERATED" ]; then
GENERATED="* Initial release"
fi
# Build release body
{
echo "## What's Changed"
echo ""
echo "$GENERATED"
echo ""
if [ -n "$PREVIOUS" ]; then
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS}..${VERSION}"
else
echo "**Full Changelog**: https://github.com/${{ github.repository }}/commits/${VERSION}"
fi
echo ""
echo "---"
echo ""
echo "## Downloads"
echo ""
echo "### Docker Compose"
echo ""
echo '```bash'
echo "docker compose pull && docker compose up -d"
echo '```'
echo ""
echo "### Docker"
echo ""
echo '```bash'
echo "docker pull ghcr.io/ohmzi/tday:latest"
echo ""
echo 'docker rm -f tday 2>/dev/null || true'
echo ""
echo "docker run -d \\"
echo " --name tday \\"
echo " -p 2525:3000 \\"
echo " --env-file .env.docker \\"
echo " --restart unless-stopped \\"
echo " ghcr.io/ohmzi/tday:latest"
echo '```'
echo ""
echo "### Portainer"
echo ""
echo "1. In Portainer: **Containers** → select **tday**"
echo "2. Click **Recreate**"
echo "3. Enable **Re-pull image**"
echo "4. Click **Recreate**"
} > body.md
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.version }}" \
--title "${{ steps.version.outputs.version }}" \
--notes-file body.md