-
Notifications
You must be signed in to change notification settings - Fork 51
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
Added Homebrew Tap Capability #520
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7472de3
Added Homebrew Tap Capability
brett-hodges be2f402
Update .github/workflows/platform-release.yaml
brett-hodges e8ffa15
Update platform-release.yaml
brett-hodges 3b27e19
Merge branch 'homebrew-tap-capabilities' of https://github.com/jozu-a…
brett-hodges 36c3c56
Update platform-release.yaml
brett-hodges b9d3d9d
Update .goreleaser.darwin.yaml
brett-hodges File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Release with Platform builds | ||
|
||
on: | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
skip_signing: | ||
|
@@ -88,6 +88,7 @@ jobs: | |
retention-days: 7 | ||
path: | | ||
./dist/*.zip | ||
./dist/*.tar.gz | ||
|
||
build-windows: | ||
runs-on: windows-latest | ||
|
@@ -145,29 +146,61 @@ jobs: | |
retention-days: 7 | ||
path: | | ||
./dist/*.tar.gz | ||
|
||
# Creates a release with the artifacts from the previous steps. | ||
# Creates a release using artifacts created in the previous steps. | ||
# workflow_dispatch triggered versions will be draft releases. | ||
# CLI docs are not updated for workflow_dispatch triggered versions. | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: [build-linux, build-macos, build-windows] | ||
steps: | ||
- name: Merge built artifacts | ||
# checkout the current repository | ||
- name: Checkout kitops | ||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
with: | ||
path: kitops | ||
|
||
# Create the homebrew-file directory to store the | ||
# homebrew artifacts | ||
- name: Create homebrew-files dir | ||
run: mkdir homebrew-files | ||
|
||
# Copy the awk script and template to the homebrew-files dir. | ||
# These will be used later to build the homebrew recipe file. | ||
- name: Copy homebrew artifacts to homebrew-files dir | ||
run: cp ./kitops/build/homebrew/*.* ./homebrew-files | ||
amisevsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Merge build artifacts | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.3 | ||
with: | ||
path: dist | ||
pattern: dist-* | ||
merge-multiple: true | ||
- name: Create Checksums | ||
|
||
- name: Create checksums | ||
env: | ||
TAG_NAME: ${{ github.ref_name}} | ||
TAG_NAME: ${{ inputs.release_tag || github.ref_name}} | ||
#TAG_NAME: ${{ inputs.release_tag}} | ||
run: | | ||
shopt -s failglob | ||
pushd dist | ||
shasum -a 256 kitops-* > checksums.txt | ||
mv checksums.txt kitops_${TAG_NAME}_checksums.txt | ||
popd | ||
shopt -s failglob | ||
pushd dist | ||
shasum -a 256 kitops-* > checksums.txt | ||
mv checksums.txt kitops_${TAG_NAME}_checksums.txt | ||
cp kitops_${TAG_NAME}_checksums.txt ../homebrew-files/. | ||
popd | ||
|
||
# upload the homebrew-files directory (and its contents) | ||
# as an artifact to be used later when generating the | ||
# homebrew recipe and pushing it to the repository: | ||
# 'jozu-ai/homebrew-kitops' | ||
- name: Upload homebrew-files as a build artifact | ||
uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1 | ||
with: | ||
name: homebrew-files | ||
if-no-files-found: error | ||
retention-days: 7 | ||
path: ./homebrew-files | ||
|
||
- name: Create Release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -178,11 +211,11 @@ jobs: | |
echo "Creating release for ${TAG_NAME}" | ||
release_args=( | ||
${TAG_NAME} | ||
./dist/*.* | ||
./dist/*.* | ||
brett-hodges marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--title "Release ${TAG_NAME}" | ||
--generate-notes | ||
--repo ${REPO} | ||
) | ||
) | ||
if [[ "${DRAFT_RELEASE}" == "false" ]]; then | ||
previous_release="$(gh release list --repo $REPO --limit 1 --json tagName --jq '.[] | .tagName ')" | ||
echo "Previous release: ${previous_release}" | ||
|
@@ -194,33 +227,108 @@ jobs: | |
fi | ||
gh release create "${release_args[@]}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
|
||
- name: Generate CLI documentation | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TAG_NAME: ${{ inputs.release_tag || github.ref_name}} | ||
run: | | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
PR_BRANCH="${{ github.ref_name }}-docs-update" | ||
git fetch origin main | ||
git branch "$PR_BRANCH" | ||
git checkout "$PR_BRANCH" | ||
git pull origin --ff-only "${PR_BRANCH}" || true | ||
|
||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
||
(cd docs; npm pkg set version=$TAG_NAME) | ||
./docs/src/docs/cli/generate.sh > /dev/null | ||
git add --all | ||
git commit -m "docs: update CLI documentation for ${{ github.ref_name }}" | ||
git push origin "${PR_BRANCH}" | ||
gh pr create --fill --base main --head "${PR_BRANCH}" | ||
git checkout "${CURRENT_BRANCH}" | ||
pushd kitops | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
PR_BRANCH="${{ github.ref_name }}-docs-update" | ||
git fetch origin main | ||
git branch "$PR_BRANCH" | ||
git checkout "$PR_BRANCH" | ||
git pull origin --ff-only "${PR_BRANCH}" || true | ||
|
||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
||
(cd docs; npm pkg set version=$TAG_NAME) | ||
./docs/src/docs/cli/generate.sh > /dev/null | ||
git add --all | ||
git commit -m "docs: update CLI documentation for ${{ github.ref_name }}" | ||
git push origin "${PR_BRANCH}" | ||
gh pr create --fill --base main --head "${PR_BRANCH}" | ||
git checkout "${CURRENT_BRANCH}" | ||
popd | ||
brett-hodges marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
# Generate and publish the homebrew recipe (kitops.rb) to the repository: | ||
# 'jozu-ai/homebrew-kitops' | ||
publish-homebrew-tap-formula: | ||
runs-on: ubuntu-latest | ||
needs: [release] | ||
steps: | ||
# checkout the homebrew-kitops repository (jozu-ai/homebrew-kitops) | ||
- name: Checkout homebrew-kitops | ||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
with: | ||
repository: jozu-ai/homebrew-kitops | ||
ref: 'main' | ||
path: homebrew-kitops | ||
token: ${{ secrets.GITOPS_PAT }} | ||
|
||
- name: Download the homebrew artifacts to build the homebrew recipe | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.3 | ||
with: | ||
name: homebrew-files | ||
path: homebrew-files | ||
merge-multiple: true | ||
|
||
- name: Create and save homebrew-metadata.txt | ||
env: | ||
TAG_NAME: ${{ inputs.release_tag}} | ||
REPO: ${{ github.repository }} | ||
run: | | ||
shopt -s failglob | ||
pushd homebrew-files | ||
awk ' | ||
BEGIN { tag_name = ENVIRON["TAG_NAME"]; repo = ENVIRON["REPO"];} | ||
/.tar.gz$/ { | ||
print "\""$1"\"", | ||
"\"https://github.com/" repo "/releases/download/" tag_name "/" $2 "\"", | ||
$2, | ||
tag_name }' kitops_${TAG_NAME}_checksums.txt | | ||
awk '{ sub(/.tar.gz/, "", $3); print $1, $2, $3, $4 }' | | ||
awk '{ sub(/kitops-/, "", $3); print $1, $2, $3, $4 }' | | ||
awk '{sub(/v/, "", $4); print $1, $2, $3, $4 }' > homebrew-metadata.txt | ||
Comment on lines
+285
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm taking it on faith that this does whatever it is supposed to -- awk is a write-only language :D Consider add comments describing what each step does? |
||
popd | ||
|
||
# uses the homebrew-metadata.txt file generated in the | ||
# previous step to generate the homebrew formula (kitops.rb) | ||
# for the homebrew tap (located at 'jozu-ai/homebrew-kitops') | ||
- name: Create homebrew formula | ||
run: | | ||
pushd homebrew-files | ||
awk -f create-homebrew-recipe.awk homebrew-metadata.txt | ||
popd | ||
|
||
# publish the homebrew recipe file to the homebrew tap | ||
# located in the repository: 'jozu-ai/homebrew-kitops' | ||
- name: Commit homebrew recipe to the homebrew tap | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITOPS_PAT }} | ||
TAG_NAME: ${{ inputs.release_tag}} | ||
REPO: "jozu-ai/homebrew-kitops" | ||
run: | | ||
cp -f ./homebrew-files/homebrew-metadata.txt ./homebrew-kitops/. | ||
cp -f ./homebrew-files/kitops.rb ./homebrew-kitops/. | ||
pushd homebrew-kitops | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
PR_BRANCH="${{ github.ref_name }}-homebrew-tap-update" | ||
git fetch origin main | ||
git branch "$PR_BRANCH" | ||
git checkout "$PR_BRANCH" | ||
git pull origin --ff-only "${PR_BRANCH}" || true | ||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | ||
git add --all | ||
git commit -m "homebrew: update Homebrew Tap Formula for ${{ github.ref_name }}" | ||
git push origin "${PR_BRANCH}" | ||
gh pr create --fill --base main --head "${PR_BRANCH}" | ||
git checkout "${CURRENT_BRANCH}" | ||
popd | ||
|
||
docker-image-build: | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Usage: awk -f create-homebrew-recipe.awk homebrew-metadata.txt | ||
|
||
BEGIN { | ||
template = "kitops.rb.template"; | ||
recipe = "kitops.rb"; | ||
} | ||
|
||
{ | ||
# Read relevant fields from input file | ||
# (intended to be homebrew-metadata.txt) | ||
shas[$3]=$1; | ||
urls[$3]=$2; | ||
version[$3]=$4; | ||
} | ||
|
||
END { | ||
# Read a line from template, replace special fields, | ||
# and print result to recipe file | ||
while ((getline ln < template) > 0) | ||
{ | ||
sub(/url @@darwin-arm64/, "url " urls["darwin-arm64"], ln); | ||
sub(/sha256 @@darwin-arm64/, "sha256 " shas["darwin-arm64"], ln); | ||
|
||
sub(/url @@darwin-x86_64/, "url " urls["darwin-x86_64"], ln); | ||
sub(/sha256 @@darwin-x86_64/, "sha256 " shas["darwin-x86_64"], ln); | ||
|
||
sub(/url @@linux-arm64/, "url " urls["linux-arm64"], ln); | ||
sub(/sha256 @@linux-arm64/, "sha256 " shas["linux-arm64"], ln); | ||
|
||
sub(/url @@linux-x86_64/, "url " urls["linux-x86_64"], ln); | ||
sub(/sha256 @@linux-x86_64/, "sha256 " shas["linux-x86_64"], ln); | ||
|
||
sub(/url @@linux-i386/, "url " urls["linux-i386"], ln); | ||
sub(/sha256 @@linux-i386/, "sha256 " shas["linux-i386"], ln); | ||
|
||
sub(/@@version/, version["darwin-arm64"], ln); | ||
|
||
print(ln) > recipe; | ||
} | ||
|
||
# Close template and recipe fields | ||
close(recipe); | ||
close(template); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Kitops < Formula | ||
desc "Packaging and versioning system for AI/ML projects" | ||
homepage "https://KitOps.ml" | ||
license "Apache-2.0" | ||
|
||
on_macos do | ||
on_arm do | ||
url @@darwin-arm64 | ||
sha256 @@darwin-arm64 | ||
end | ||
on_intel do | ||
url @@darwin-x86_64 | ||
sha256 @@darwin-x86_64 | ||
end | ||
|
||
end | ||
|
||
on_linux do | ||
on_arm do | ||
url @@linux-arm64 | ||
sha256 @@linux-arm64 | ||
end | ||
on_intel do | ||
if Hardware::CPU.is_64_bit? | ||
url @@linux-x86_64 | ||
sha256 @@linux-x86_64 | ||
else | ||
url @@linux-i386 | ||
sha256 @@linux-i386 | ||
end | ||
end | ||
end | ||
|
||
def install | ||
bin.install "kit" | ||
end | ||
|
||
test do | ||
expected_version = "Version: @@version" | ||
actual_version = shell_output("#{bin}/kit version").strip | ||
assert_match expected_version, actual_version | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few trailing spaces on lines in this file (in VS Code, use
cmd+k, cmd+z
to trim)