-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make date-based version easier to read
- Loading branch information
Showing
5 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,8 @@ on: [push, pull_request] | |
|
||
jobs: | ||
|
||
create-version-suffix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version-suffix: ${{ steps.create-version-suffix.outputs.VERSION_SUFFIX }} | ||
steps: | ||
- id: create-version-suffix | ||
shell: pwsh | ||
run: | | ||
$versionSuffix = [System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss") | ||
$versionString = "VERSION_SUFFIX=$versionSuffix" | ||
Write-Host $versionString | ||
Write-Output $versionString | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | ||
build: | ||
runs-on: ${{ matrix.value.os }} | ||
needs: create-version-suffix | ||
strategy: | ||
matrix: | ||
value: [{ os: windows-latest, architecture: x64 }, { os: windows-latest, architecture: arm64 }, { os: ubuntu-latest, architecture: x64 }] | ||
|
@@ -34,13 +20,9 @@ jobs: | |
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.19 | ||
- name: promote version suffix | ||
shell: pwsh | ||
run: | | ||
Write-Output "VERSION_SUFFIX=${{ needs.create-version-suffix.outputs.version-suffix }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
- name: Build and test | ||
shell: pwsh | ||
run: ./build-and-test.ps1 -configuration Release -architecture ${{ matrix.value.architecture }} | ||
run: ./build-and-test.ps1 -configuration Release -architecture ${{ matrix.value.architecture }} -ci | ||
- name: publish artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
|
@@ -55,17 +37,24 @@ jobs: | |
|
||
cross_compile: | ||
runs-on: ubuntu-latest | ||
needs: create-version-suffix | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Calculate version | ||
shell: bash | ||
run: echo "VERSION_SUFFIX=$(pwsh ./build/make-version.ps1 -suffix beta)" | tee -a $GITHUB_ENV | ||
- uses: devcontainers/[email protected] | ||
env: | ||
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }} | ||
with: | ||
push: never | ||
runCmd: ./build-and-test.ps1 -configuration Release -architecture arm64 | ||
env: | | ||
VERSION_SUFFIX=${{ needs.create-version-suffix.outputs.version-suffix }} | ||
DOTNET_NOLOGO=true | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true | ||
DOTNET_CLI_TELEMETRY_OPTOUT=true | ||
VERSION_SUFFIX | ||
- name: re-map path variables from container | ||
shell: pwsh | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/pwsh | ||
|
||
[CmdletBinding(PositionalBinding = $false)] | ||
param ( | ||
[string]$suffix = "dev" | ||
) | ||
|
||
Set-StrictMode -version 2.0 | ||
$ErrorActionPreference = "Stop" | ||
|
||
try { | ||
# get date of latest commit | ||
$date = git show --no-patch --format=%cs HEAD | ||
|
||
# count commits with that same date | ||
$lines = git log '--pretty=%cs' -n 99 | ||
$count = 0 | ||
foreach ($line in $lines) { | ||
if ($line -ne $date) { | ||
break | ||
} | ||
|
||
$count++ | ||
} | ||
|
||
# format date as version | ||
$parts = $date -Split '-' | ||
$year = $parts[0] # e.g., 2024 from '2024-12-25' | ||
$month = $parts[1] # e.g., 12 from '2024-12-25' | ||
$day = $parts[2] # e.g., 25 from '2024-12-25' | ||
$version = "$suffix.$year-$month-$day.$count" | ||
Write-Output $version | ||
|
||
} | ||
catch { | ||
Write-Host $_ | ||
Write-Host $_.Exception | ||
Write-Host $_.ScriptStackTrace | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2 | ||
0.2.0 |