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 e1816dd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
# This is a basic workflow to help you get started with Actions

name: Build Bulma4Hugo
name: Build Bulma 4 Hugo

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: ["main"]
pull_request:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# defaults:
# run:
# shell: powershell

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-2019
runs-on: windows-latest

# Steps represent a sequence of tasks that will be executed as part of the job
permissions:
contents: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Runs a set of commands using the runners shell
- name: Configure Git
run: |
git config --local core.autocrlf "auto"
git config --local user.name "irkode"
git config --global user.email "irkode@rikode.de"
- 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
Expand All @@ -42,4 +38,3 @@ jobs:
- name: Cleanup
run: |
Remove-Item -Recurse -Force .\src
tree /f .
56 changes: 37 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,34 @@ 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
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
git push --tags
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 e1816dd

Please sign in to comment.