Skip to content

Commit

Permalink
add branching and tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
irkode committed Jul 27, 2024
1 parent a18f38e commit 516c984
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
58 changes: 39 additions & 19 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 516c984

Please sign in to comment.