Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
https://docs.go-blueprint.dev/
MIT License
5.88k stars 333 forks source link

[Feature Request] Automatically include most recent version of HTMX #198

Closed briancbarrow closed 7 months ago

briancbarrow commented 8 months ago

Tell us about your feature request

After merging this PR I was thinking we probably just want to grab the most recent version automatically.

Would it make sense if we just send a GET request to https://unpkg.com/htmx.org , which will send back the most recent minified code, and then dump that into the generated file/folder structure?

Disclaimer

H0llyW00dzZ commented 8 months ago

Tell us about your feature request

After merging this PR I was thinking we probably just want to grab the most recent version automatically.

Would it make sense if we just send a GET request to https://unpkg.com/htmx.org , which will send back the most recent minified code, and then dump that into the generated file/folder structure?

Disclaimer

  • [x] I agree

that will be great, I agree

Ujstor commented 8 months ago

@briancbarrow I made some progress, check htmx version is working. The next step is to figure out how to open a PR with artifact automatically.

name: Check for new htmx release

on:
  schedule:
    - cron: '0 0 * * Sun'
  workflow_dispatch:

jobs:
  check_release:
    runs-on: ubuntu-latest
    steps:
      - name: Get version from file
        id: get_version_file
        run: |
          VERSION_FILE=$(curl https://raw.githubusercontent.com/Melkeydev/go-blueprint/main/cmd/template/advanced/files/htmx/htmx.min.js.tmpl | grep version | awk -F'"' '{print "v" $2}')
          echo "version file: $VERSION_FILE"

      - name: Get version from GitHub API
        id: get_version_api
        run: |
          VERSION_API=$(curl -s https://api.github.com/repos/bigskysoftware/htmx/releases/latest | jq -r '.tag_name')
          echo "version api: $VERSION_API"

      - name: Compare versions
        id: compare_versions
        run: |
          if [ "$VERSION_API" != "$VERSION_FILE" ]; then
            echo "release_changed=true" >> $GITHUB_OUTPUT
            echo "Release changed: true"
          else
            echo "release_changed=false" >> $GITHUB_OUTPUT
            echo "Release changed: false"
          fi

      - name: Call workflow to build code
        if: steps.compare_versions.outputs.release_changed == 'true'
        uses: benc-uk/workflow-dispatch@v1
        with:
          workflow: update-htmx-version.yml