Skip to content

Commit ddfa3d1

Browse files
committed
chore: dynamic version on web
1 parent 882dfea commit ddfa3d1

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

.github/workflows/deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
working-directory: tools/sitemap
2525
run: go run . -docs ${{ github.workspace }}/web/docs -out ${{ github.workspace }}/web/sitemap.xml
2626

27+
- name: Inject version into HTML
28+
run: |
29+
VERSION="${GITHUB_REF_NAME}"
30+
find ./web -name '*.html' -exec sed -i "s/__VERSION__/${VERSION}/g" {} +
31+
2732
- name: Deploy via SFTP
2833
run: |
2934
sudo apt-get update -qq && sudo apt-get install -y -qq lftp

Taskfile.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ tasks:
7676
web:dev:
7777
desc: Serve website locally with Apache (port 8080)
7878
deps: [docs, sitemap]
79-
cmd: >-
80-
docker run --rm -p 8080:80
81-
-v "$PWD/web":/usr/local/apache2/htdocs/
82-
-v "$PWD/web/httpd-dev.conf":/usr/local/apache2/conf/extra/dev.conf
83-
httpd:alpine
84-
sh -c "echo 'Include conf/extra/dev.conf' >> /usr/local/apache2/conf/httpd.conf && httpd-foreground"
79+
vars:
80+
WEB_VERSION:
81+
sh: git describe --tags --abbrev=0 2>/dev/null || echo "dev"
82+
cmds:
83+
- find ./web -name '*.html' -exec sed -i '' 's/__VERSION__/{{.WEB_VERSION}}/g' {} +
84+
- defer: find ./web -name '*.html' -exec sed -i '' 's/{{.WEB_VERSION}}/__VERSION__/g' {} +
85+
- >-
86+
docker run --rm -p 8080:80
87+
-v "$PWD/web":/usr/local/apache2/htdocs/
88+
-v "$PWD/web/httpd-dev.conf":/usr/local/apache2/conf/extra/dev.conf
89+
httpd:alpine
90+
sh -c "echo 'Include conf/extra/dev.conf' >> /usr/local/apache2/conf/httpd.conf && httpd-foreground"

web/css/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ code, pre {
164164
color: var(--text-primary);
165165
}
166166

167+
.nav-version {
168+
font-size: 0.8rem;
169+
font-weight: 500;
170+
color: var(--text-secondary);
171+
opacity: 0.7;
172+
margin-top: 3px;
173+
margin-left: -2px;
174+
}
175+
167176
.nav-icon {
168177
color: var(--accent);
169178
}

web/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<path d="M200.391 144.281H259.706C267.722 144.281 270.928 153.9 264.516 158.709L234.056 184.359C230.85 187.566 226.041 187.566 222.834 184.359L192.375 158.709C185.963 153.9 190.772 144.281 197.184 144.281H200.391Z" fill="white"/>
8585
</svg>
8686
<span>Hourgit</span>
87+
<span class="nav-version">__VERSION__</span>
8788
</a>
8889
<div class="nav-links">
8990
<a href="#how-it-works">How it works</a>
@@ -164,11 +165,11 @@ <h3>Install in seconds</h3>
164165
</div>
165166
<pre><code><span class="t-prompt">$</span> curl -fsSL https://hourgit.com/install.sh | bash
166167
<span class="t-output">info Platform: darwin/arm64
167-
info Latest version: <span class="t-accent">v0.8.0</span>
168-
info Downloading hourgit-darwin-arm64-v0.8.0...
168+
info Latest version: <span class="t-accent">__VERSION__</span>
169+
info Downloading hourgit-darwin-arm64-__VERSION__...
169170
info Checksum verified
170171
info Installed to <span class="t-accent">~/.hourgit/bin/hourgit</span>
171-
<span class="t-success">Hourgit v0.8.0 installed successfully!</span></span></code></pre>
172+
<span class="t-success">Hourgit __VERSION__ installed successfully!</span></span></code></pre>
172173
</div>
173174
</div>
174175
</div>

0 commit comments

Comments
 (0)