Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix brew-update util, and add CI #207

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/brew-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Update Homebrew Formulae
on:
release:
types: [released]

workflow_dispatch:
push:
branches: [main]
paths:
- .github/workflows/brew-update.yaml

jobs:
Update:
runs-on: macos-latest
steps:
- name: Tap
run: |
brew tap ${{ github.repository_owner }}/yamlscript
brew install ys

- name: Livecheck
id: livecheck
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}
run: |
brew livecheck --newer-only --quiet --json ys |
jq --raw-output '"version=\(.[].version.latest)"' >> $GITHUB_OUTPUT

- name: Checkout
if: steps.livecheck.outputs.version != ''
uses: actions/checkout@v4

- name: Configure Git
if: steps.livecheck.outputs.version != ''
run: |
git config --global user.name ${{ github.repository_owner }}
git config --global user.email ${{ github.event.pusher.email }}

- name: Bump Version
if: steps.livecheck.outputs.version != ''
env:
version: ${{ steps.livecheck.outputs.version }}
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
util/brew-update $version
cd homebrew-yamlscript
gh auth setup-git
git add --all
git commit --message "Update $version"
git push
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,6 @@ ifndef d
endif

release-yamlscript: $(BUILD_BIN_YS)
ifneq (main, $(shell git rev-parse --abbrev-ref HEAD))
$(error You must be on the 'main' branch to release)
endif
ifndef o
$(error Please set Makefile variable o=#.#.#)
endif
ifndef n
$(error Please set Makefile variable n=#.#.#)
endif
@[[ $$YS_GH_USER ]] || { \
echo 'Please export YS_GH_USER'; exit 1; }
@[[ $$YS_GH_TOKEN ]] || { \
echo 'Please export YS_GH_TOKEN'; exit 1; }
(time $< $(ROOT)/util/release-yamlscript $o $n $s) 2>&1 | \
tee -a $(RELEASE_LOG)

Expand Down
17 changes: 12 additions & 5 deletions util/brew-update
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/usr/bin/env ys-0

releases-url =: 'https://github.com/yaml/yamlscript/releases'
brew-url =: '[email protected]:yaml/homebrew-yamlscript'
repo =: ENV.GITHUB_REPOSITORY_OWNER || 'yaml'
brew-url =: "https://github.com/$repo/homebrew-yamlscript"

defn main(version):
check-version: version
download-releases: version
update-brew: version

os =: System/getProperty('os.name')

defn sha256sum(file):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love to see you refactoring with YS code!

sh:
if os =~ /Mac\s?OS/:
then: "shasum -a 256 $file"
else: "sha256sum $file"

defn update-brew(version):
releases =: releases(version)

Expand All @@ -22,7 +31,7 @@ defn update-brew(version):
text =:
reduce-kv _ text releases:
fn(text key file):
sha256 =: sh("sha256sum $file").out:words.0
sha256 =: sha256sum(file).out:words.0
text: .replace(key sha256)

say: "Updating homebrew-yamlscript/ys.rb"
Expand Down Expand Up @@ -51,9 +60,7 @@ defn download-releases(version):
when-not fs-e(file):
say: "Downloading $file"
url =: "$releases-url/download/$version/$file"
res =: sh("wget -q $url")
when res.exit:N.?:
die: "Download of '$url' failed:\n$(res.err)"
spit file: curl(url)

defn releases(version)::
LIN_ARM:: "ys-${version}-linux-aarch64.tar.xz"
Expand Down
2 changes: 1 addition & 1 deletion util/markys
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ys-0

input-dir =: A(nil)
input-dir =: atom(nil)

DNE =: "<!-- DO NOT EDIT — THIS FILE WAS GENERATED -->\n\n"

Expand Down
2 changes: 0 additions & 2 deletions util/release-yamlscript
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ defn step-8(ctx):
defn step-9(ctx):
o: "Step 9) Run 'make release-assets'"

prompt: 'Press Enter when ready to continue.'

run:: make test-core test-ys

run:: make release-assets
Expand Down