Skip to content

Commit c3ef401

Browse files
committed
Updated action for manual deploy
1 parent a633395 commit c3ef401

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ jobs:
3838
- name: Install .NET workloads
3939
run: dotnet workload install wasm-tools
4040

41+
- name: Generate version number
42+
id: version
43+
run: |
44+
UTC_DATE=$(date -u '+%Y.%m.%d')
45+
START_OF_DAY=$(date -u -d "today 00:00:00" '+%s')
46+
CURRENT_TIME=$(date -u '+%s')
47+
SECONDS_SINCE_MIDNIGHT=$(( (CURRENT_TIME - START_OF_DAY) / 2 ))
48+
VERSION="$UTC_DATE.$SECONDS_SINCE_MIDNIGHT"
49+
echo "version=$VERSION" >> $GITHUB_OUTPUT
50+
echo "Generated version: $VERSION"
51+
4152
- name: Setup Pages
4253
uses: actions/configure-pages@v5
4354

@@ -47,7 +58,7 @@ jobs:
4758
dotnet restore
4859
4960
- name: Build Blazor WebAssembly
50-
run: dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/
61+
run: dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/ -p:Version=${{ steps.version.outputs.version }}
5162

5263
- name: Copy index.html to 404.html
5364
run: cp dist/wwwroot/index.html dist/wwwroot/404.html
@@ -64,6 +75,12 @@ jobs:
6475
sed -i 's|"hash": "[^"]*"|"hash": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="|g' "$jsFile"
6576
fi
6677
78+
- name: Add version info to site
79+
working-directory: dist/wwwroot
80+
run: |
81+
echo '{"version":"${{ steps.version.outputs.version }}","buildDate":"$(date -u +%Y-%m-%dT%H:%M:%SZ)","commit":"${{ github.sha }}","run":"${{ github.run_id }}"}' > version.json
82+
echo "<!-- Build: ${{ steps.version.outputs.version }} | Commit: ${{ github.sha }} | Run: ${{ github.run_id }} -->" >> index.html
83+
6784
- name: Change base-tag in index.html from / to BlazorTextDiff
6885
working-directory: dist/wwwroot
6986
run: sed -i 's/<base href="\/" \/>/<base href="\/BlazorTextDiff\/" \/>/g' index.html
@@ -75,6 +92,7 @@ jobs:
7592
- name: Upload artifact
7693
uses: actions/upload-pages-artifact@v3
7794
with:
95+
name: github-pages-${{ steps.version.outputs.version }}
7896
path: dist/wwwroot
7997

8098
deploy:

.github/workflows/publish-packages.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ jobs:
8080
- name: Check if should publish
8181
id: check-publish
8282
run: |
83-
if [[ "${{ github.event_name }}" == "push" && ("${{ github.ref }}" == "refs/heads/master" || "${{ github.ref }}" == "refs/heads/main") ]]; then
83+
if [[ ("${{ github.event_name }}" == "push" && ("${{ github.ref }}" == "refs/heads/master" || "${{ github.ref }}" == "refs/heads/main")) || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
8484
echo "should-publish=true" >> $GITHUB_OUTPUT
85-
echo "Will publish packages"
85+
echo "Will publish packages (triggered by: ${{ github.event_name }})"
8686
else
8787
echo "should-publish=false" >> $GITHUB_OUTPUT
88-
echo "Will not publish packages (not a push to main/master branch)"
88+
echo "Will not publish packages (event: ${{ github.event_name }}, ref: ${{ github.ref }})"
8989
fi
9090
9191
- name: Upload build artifacts
9292
uses: actions/upload-artifact@v4
9393
with:
94-
name: ${{ env.ARTIFACT_NAME }}
94+
name: ${{ env.ARTIFACT_NAME }}-${{ steps.version.outputs.version }}
9595
path: ./artifacts/*.nupkg
9696
if-no-files-found: error
9797

@@ -113,7 +113,7 @@ jobs:
113113
- name: Download artifacts
114114
uses: actions/download-artifact@v4
115115
with:
116-
name: ${{ env.ARTIFACT_NAME }}
116+
name: ${{ env.ARTIFACT_NAME }}-${{ needs.build-and-test.outputs.version }}
117117
path: ./artifacts
118118

119119
- name: Publish to GitHub Packages
@@ -138,7 +138,7 @@ jobs:
138138
- name: Download artifacts
139139
uses: actions/download-artifact@v4
140140
with:
141-
name: ${{ env.ARTIFACT_NAME }}
141+
name: ${{ env.ARTIFACT_NAME }}-${{ needs.build-and-test.outputs.version }}
142142
path: ./artifacts
143143

144144
- name: Publish to NuGet.org
@@ -163,7 +163,7 @@ jobs:
163163
- name: Download artifacts
164164
uses: actions/download-artifact@v4
165165
with:
166-
name: ${{ env.ARTIFACT_NAME }}
166+
name: ${{ env.ARTIFACT_NAME }}-${{ needs.build-and-test.outputs.version }}
167167
path: ./artifacts
168168

169169
- name: Create Release

0 commit comments

Comments
 (0)