From 516c9847c95d397121f0fb6a613a835b701e1a38 Mon Sep 17 00:00:00 2001 From: irkode Date: Sat, 27 Jul 2024 09:22:27 +0200 Subject: [PATCH] add branching and tagging --- .github/workflows/build.yml | 3 +- build.ps1 | 58 +++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8638f8..c892242 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,14 +32,13 @@ jobs: # Runs a set of commands using the runners shell - name: Init scripts run: | - $PSVersionTable | Format-List | Out-Host [void](New-Item -Type Directory ./src -ErrorAction Stop) Copy-Item ./build.ps1 ./src -ErrorAction Stop Remove-Item ./build.ps1 -ErrorAction Stop - name: Package Bulma run: | ./src/build.ps1 -ErrorAction Stop + git push - name: Cleanup run: | Remove-Item -Recurse -Force .\src - tree /f . diff --git a/build.ps1 b/build.ps1 index fbee256..d67d5aa 100644 --- a/build.ps1 +++ b/build.ps1 @@ -4,10 +4,14 @@ $BULMA_URL = "https://api.github.com/repos/jgthms/bulma" # get releases and extract needed information $BulmaReleases = Invoke-RestMethod -FollowRelLink -Uri "$BULMA_URL/releases?per_page=100" | %{$_}| ForEach-Object { - [PSCustomObject]@{ - version = [version]$_.tag_name - archive = [string]$_.assets.name - download = [string]$_.assets.browser_download_url + if ($_.tag_name) { + [PSCustomObject]@{ + version = [version]$_.tag_name + archive = [string]$_.assets.name + download = [string]$_.assets.browser_download_url + } + } else { + Write-Warning "found untagged release for $($_.assets.name)" } } | Sort-Object -Property version $tags = git tag @@ -17,20 +21,36 @@ foreach ($release in $BulmaReleases) { continue } # download + Write-Output "new release : $release" $archive = Join-Path -Path $TEMPDIR -ChildPath $release.archive - if (Test-Path -Path $archive) { - Write-Output "is downloaded : $release" - continue - } else { - Write-Output "new release : $release" - Invoke-WebRequest -Uri $release.download -OutFile $archive - break - } + Invoke-WebRequest -Uri $release.download -OutFile $archive + $bulmaFolder = (Get-Item $archive).Basename + Remove-Item -Recurse .\assets -ErrorAction SilentlyContinue + if (Test-Path .\assets) { throw ".\assets should not exist"} + if (Test-Path .\build.ps1) { throw ".\build.ps1 should not exist"} + git checkout -b $bulmaFolder + git status + [void](New-Item -Type Directory ./assets -ErrorAction Stop) + if (-Not (Test-Path .\assets -PathType Container)) { throw ".\assets should exist"} + Expand-Archive -LiteralPath $archive -DestinationPath .\assets + if (Test-Path .\assets\__MACOSX) { Remove-Item .\assets\__MACOSX -ErrorAction SilentlyContinue -Recurse } + Rename-Item .\assets\$bulmaFolder "bulma" + dir . + dir .\assets + if (-Not (Test-Path ./assets/bulma -PathType Container)) { throw "missing ./assets/bulma folder"} + git add assets\bulma + git config --local core.autocrlf "true" + git config --local user.name "irkode" + git config --global user.email "irkode@rikode.de" + Write-Output "committing..." + git commit -m "add $bulmaFolder" + Write-Output "tagging..." + git tag --annotate $release.version -m "release Bulma 4 Hugo v$($release.version)" + Write-Output "remove branch..." + git checkout main + git branch -D $bulmaFolder + git log --oneline -n 5 + git tag + git branch + break } -$bulmaFolder = (Get-Item $archive).Basename -[void](Remove-Item -Recurse .\assets -ErrorAction SilentlyContinue) -if ( Test-Path .\assets) { throw ".\assets should not exist"} -Expand-Archive -LiteralPath $archive -DestinationPath . -Rename-Item $bulmaFolder "assets" -[void](Remove-Item __MACOSX -ErrorAction SilentlyContinue -Recurse) -git status