Skip to content

Commit

Permalink
Automatate scoop manifest updates (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack authored Mar 5, 2025
2 parents cdc908a + 7eec7af commit cd77f5b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ f4c9fc1dceb03abc7b944757a8ec73fa361f30e8

# Switch heuristics to single quotes
b67e485e1182063787a48a495afdf0e24af9e544

# Format scoop manifest
c2b4032cb45697b1957c5620f381ff3e38fce2d1
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,25 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

scoop:
name: Update scoop manifest
if: ${{ github.event_name != 'workflow_dispatch' }}
needs: github
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAG: ${{ github.ref_name }}

steps:
- uses: actions/checkout@v4
- name: Update manifest for ${{ env.TAG }}
run: './scripts/update-scoop.rb ./scoop/gengo.json "${TAG}"'
- name: Commit and push changes
run: |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config --global user.name 'github-actions[bot]'
git add ./scoop/gengo.json
git commit -m "Update scoop manifest for ${TAG}"
git push
23 changes: 11 additions & 12 deletions scoop/gengo.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"version": "0.12.1",
"description": "A linguist-inspired language classifier with multiple file source handlers",
"homepage": "https://github.com/spenserblack/gengo",
"license": "MIT | Apache-2.0",
"url": "https://github.com/spenserblack/gengo/releases/download/v0.12.1/gengo-x86_64-pc-windows-msvc.tar.gz",
"hash": "c799d64cf2cb8ef5ce5407ca76cd3bd949a8847bee14e79a29865f1e984a8034",
"bin": "gengo.exe",
"checkver": "github",
"autoupdate": {
"url": "https://github.com/spenserblack/gengo/releases/download/v$version/gengo-x86_64-pc-windows-msvc.tar.gz"
}
"version": "0.12.1",
"description": "A linguist-inspired language classifier with multiple file source handlers",
"homepage": "https://github.com/spenserblack/gengo",
"license": "MIT | Apache-2.0",
"url": "https://github.com/spenserblack/gengo/releases/download/v0.12.1/gengo-x86_64-pc-windows-msvc.tar.gz",
"hash": "c799d64cf2cb8ef5ce5407ca76cd3bd949a8847bee14e79a29865f1e984a8034",
"bin": "gengo.exe",
"checkver": "github",
"autoupdate": {
"url": "https://github.com/spenserblack/gengo/releases/download/v$version/gengo-x86_64-pc-windows-msvc.tar.gz"
}
}

23 changes: 23 additions & 0 deletions scripts/update-scoop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
require "json"

if ARGV.length != 2
warn "Usage: #{$PROGRAM_NAME} <scoop-manifest.json> <tag>"
exit 1
end

path = ARGV[0]
tag = ARGV[1]
# Make version plain X.Y.Z without "v" prefix
version = tag.delete_prefix("v")

manifest = JSON.load_file(path)
manifest["version"] = version
manifest["url"] = "https://github.com/spenserblack/gengo/releases/download/#{tag}/gengo-x86_64-pc-windows-msvc.tar.gz"
pretty = JSON.pretty_generate(manifest)

File.open(path, "w") do |file|
file.write(pretty)
# Final newline
file.write("\n")
end

0 comments on commit cd77f5b

Please sign in to comment.