From c440138d435abb91fcfc7ddf4d04c86ab496d3e2 Mon Sep 17 00:00:00 2001 From: irkode Date: Mon, 22 Jul 2024 20:47:51 +0200 Subject: [PATCH] add workflow to pack first unknown Bulma release --- .github/workflows/build.yml | 107 ++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++ README.md | 112 ++++++++++++++++++++++++++++++++++++ go.mod | 3 + 4 files changed, 243 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 go.mod diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ef6513d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,107 @@ +# This is a basic workflow to help you get started with Actions + +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"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + env: + GH_TOKEN: ${{ github.token }} + BULMA_URL: "https://api.github.com/repos/jgthms/bulma" + 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 "false" + git config --local user.name ${{ secrets.GH_USER_NAME }} + git config --global user.email ${{ secrets.GH_USER_MAIL }} + git fetch --tags + - name: Prepare repository + run: | + # cleanup rubbish from the past + Remove-Item -Recurse .\assets -ErrorAction SilentlyContinue + Remove-Item -Recurse .\.github -ErrorAction SilentlyContinue + Remove-Item .\.gitignore -ErrorAction SilentlyContinue + [void](Test-Path .\assets -ErrorAction Stop) + [void](Test-Path .\.github -ErrorAction Stop) + [void](Test-Path .\.gitignore -ErrorAction Stop) + + - name: Download Bulma + run: | + $Tags = git tag + Write-Output "Known Bulma tags:" + $tags | Format-Table | Out-Host + # get list of Bulma Releases + $BulmaReleases = Invoke-RestMethod -FollowRelLink -Uri "$($Env:BULMA_URL)/releases?per_page=100" | %{$_}| ForEach-Object { + if ($_.tag_name -and (-Not ($_.draft -and $_.prerelease))) { + [PSCustomObject]@{ + release = [version]$_.tag_name + known = [bool]$($Tags -contains $_.tag_name) + archive = [string]$_.assets.name + download = [string]$_.assets.browser_download_url + } + } + } | Sort-Object -Property release + Write-Output "All BULMA Releases" + $BulmaReleases | FT | Out-Host + $BulmaRelease = $BulmaReleases | Where-Object { -Not $_.known } | Select-Object -First 1 + if ($BulmaRelease) { + Write-Output "Downloading Bulma $($BulmaRelease.release)" + Invoke-WebRequest -Uri $BulmaRelease.download -OutFile $BulmaRelease.archive + [void](Test-Path $BulmaRelease.archive -ErrorAction Stop) + $bulmaFolder = (Get-Item $BulmaRelease.archive).Basename + + [void](New-Item -Type Directory ./assets -ErrorAction Stop) + [void](Test-Path .\assets -PathType Container -ErrorAction Stop) + Expand-Archive -LiteralPath $BulmaRelease.archive -DestinationPath .\assets + if (Test-Path .\assets\__MACOSX) { Remove-Item .\assets\__MACOSX -ErrorAction SilentlyContinue -Recurse } + Rename-Item .\assets\$bulmaFolder "bulma" + [void](Test-Path ./assets/bulma -PathType Container -ErrorAction Stop) + if ((Get-ChildItem .\assets).Count -ne 1) { + Write-Error "Unknown Bulma archive content found (expected 'bulma' only):" + Get-ChildItem .\assets | Out-Host + Write-Error "Aborting - please check" + } + Remove-Item $BulmaRelease.archive -ErrorAction SilentlyContinue + [void](Test-Path $BulmaRelease.archive -ErrorAction Stop) + echo "BULMA_RELEASE=$($BulmaRelease.release)" | Out-File $Env:GITHUB_ENV -Append -Encoding utf8 + echo "BULMA_ARCHIVE=$($BulmaRelease.archive)" | Out-File $Env:GITHUB_ENV -Append -Encoding utf8 + Write-Output "download successful: $($BulmaRelease.archive)" + } else { + Write-Output "No new Bulma Version found to pack" + } + - name: Create Release + if: ${{ env.BULMA_RELEASE }} + run: | + Write-Host "Creating Release for $ENV:BULMA_RELEASE : $ENV:BULMA_ARCHIVE" + $BulmaRelease = "$ENV:BULMA_RELEASE" + $BulmaArchive = "$ENV:BULMA_ARCHIVE" + $cwd = ($pwd.Path -replace "\\","\\") + "\\" + (Get-ChildItem .).FullName -replace $cwd, ""|sort + $bulmaBranch = "bulma-$BulmaRelease" + git checkout -b $bulmaBranch + git add assets .github + git commit -m "pack Bulma $BulmaRelease for Hugo" + git push --set-upstream origin $bulmaBranch + # git tag -a "$BulmaRelease" -m "packed Bulma release $BulmaRelease" + # git push --tags + git checkout main + gh auth login + gh release create $BulmaRelease --title "Bulma4Hugo v$BulmaRelease" --target $bulmaBranch + git branch -D $bulmaBranch + git push origin --delete $bulmaBranch diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5e5c481 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Irkode + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..623f49b --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +# **Bulma4Hugo** - Use _Bulma_ easily within your _Hugo_ site + +_Bulma_ releases packaged for use with _Hugo_ as module or using git. + +## Features + +- access to all build variants from _Bulma_ release. +- choose a precompiled CSS variant +- use the SASS and your build pipeline + - customize SASS if you want +- easy version change (depending on your chosen usage) + +## Disclaimer + +This is a brute force repacking of _Bulma_ release to ease up adding it to a _Hugo_ site. + +- There's no stuff like verification and testing. +- delivered as-is, no guarantee no warranty +- No _Bulma_ support here + +## Support + +If you have problems/issues with _Bulma_ itself, please use the [_Bulma_ issue tracker](https://github.com/jgthms/_Bulma_/issues). + +Anything regarding packaging may be addressed here [Bulma4Hugo](https://github.com/irkode/Bulma4Hugo) + +## Use Bulma4Hugo in your _Hugo_ project + +Set up a you _Hugo_ site and `cd` to site root folder. + +Add **Bulma\_ 4 \_Hugo** to your site using one of the below methods + +### _Hugo_ module (preferred) + +- First [install Go](https://go.dev/doc/install) (needed for _Hugo_ modules) + +- add the module to your site config file: + + - _Hugo_.yaml + + ```yaml + module: + imports: + - path: github.com/irkode/Bulma4Hugo + ``` + + - _Hugo_.toml + + ```toml + [module] + [module.imports] + path = github.com/irkode/Bulma4Hugo + ``` + +### Git + +In your site root folder choose the method you want + +- Clone + + ``` + git clone https://github.com/irkode/Bulma4Hugo.git themes/Bulma4Hugo + ``` + +- Submodule + + ``` + git submodule add https://github.com/irkode/Bulma4Hugo.git themes/Bulma4Hugo + ``` + +Add the Theme to your site configuration + +- _Hugo_.yaml + + ```yaml + theme: Bulma4Hugo + # use array syntax if you need other themes, too + theme: + - Bulma4Hugo + - othertheme + ... + ``` + +- _Hugo_.toml + + ```toml + theme = "Bulma4Hugo" + # use array syntax if you need other themes, too + theme = ["Bulma4Hugo", "othertheme", ...] + ``` + +## Use _Bulma_ + +After installing Bulma4Hugo you may refer to the _Bulma_ css, sass files using `/assets/_Bulma_` + +Just follow the [Official _Bulma_ documentation](https://_Bulma_.io/). + +In general you will use [_Hugo_ Asset Management](https://go_Hugo_.io/categories/asset-management/) to add _Bulma_ tzo your site. + +## Releases + +**Bulma\_ 4 \_Hugo** follows the _Bulma_ release scheme. So version numbers are same. + +Only tagged releases are available. + +New _Bulma_ releases should be added shortly after published. + +## Licensing + +This is just a repack of _Bulma_. The packer itself is [MIT licensed](./LICENSE) + +For _Bulma_ Licensing terms consult the _Bulma_ Documentation at [_Bulma_ Licensing and Copyright](https://github.com/jgthms/_Bulma_#copyright-and-license-) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8004a20 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/irkode/bulma4hugo + +go 1.22.2