-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jkowalleck/chore/automation-init
chore: automate formula updates
- Loading branch information
Showing
6 changed files
with
221 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -e | ||
# Purpose: generate a forumla for "CycloneDX-gomod" | ||
|
||
UF_REPO='CycloneDX/cyclonedx-cli' | ||
UF_VERSION="$1" | ||
|
||
THIS_DIR="$(realpath "$(dirname "$0")" )" | ||
TMP_DIR="$(mktemp -d "$THIS_DIR/.tmp.fu.XXXXXXXX")" | ||
|
||
formula="$(< "$THIS_DIR/template.rb")" | ||
|
||
gh release download \ | ||
"v${UF_VERSION}" \ | ||
--repo "$UF_REPO" \ | ||
--pattern "cyclonedx-osx-*" \ | ||
--pattern "cyclonedx-linux-*" \ | ||
--dir "$TMP_DIR" \ | ||
1>&2 | ||
|
||
for _target in 'osx-x64' 'osx-arm64' 'linux-arm64' 'linux-arm' 'linux-x64' | ||
do | ||
_sha256sum="$(sha256sum -b "${TMP_DIR}/cyclonedx-${_target}" | cut -f1 -d' ')" | ||
formula=${formula//%SHA256SUM_${_target}%/$_sha256sum} | ||
done | ||
|
||
rm -rf "$TMP_DIR" 1>&2 | ||
|
||
echo "${formula//%VERSION%/$UF_VERSION}" |
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,56 @@ | ||
class CyclonedxCli < Formula | ||
desc "CycloneDX CLI tool for SBOM analysis, merging, diffs and format conversions." | ||
homepage "https://cyclonedx.org" | ||
version "%VERSION%" | ||
license "Apache-2.0" | ||
|
||
on_macos do | ||
if Hardware::CPU.intel? | ||
url "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v%VERSION%/cyclonedx-osx-x64", :using => :nounzip | ||
sha256 "%SHA256SUM_osx-x64%" | ||
|
||
def install | ||
bin.install "cyclonedx-osx-x64" => "cyclonedx" | ||
end | ||
end | ||
if Hardware::CPU.arm? | ||
url "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v%VERSION%/cyclonedx-osx-arm64" | ||
sha256 "%SHA256SUM_osx-arm64%" | ||
|
||
def install | ||
bin.install "cyclonedx-osx-arm64" => "cyclonedx" | ||
end | ||
end | ||
end | ||
|
||
on_linux do | ||
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? | ||
url "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v%VERSION%/cyclonedx-linux-arm64", :using => :nounzip | ||
sha256 "%SHA256SUM_linux-arm64%" | ||
|
||
def install | ||
bin.install "cyclonedx-linux-arm64" => "cyclonedx" | ||
end | ||
end | ||
if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? | ||
url "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v%VERSION%/cyclonedx-linux-arm", :using => :nounzip | ||
sha256 "%SHA256SUM_linux-arm%" | ||
|
||
def install | ||
bin.install "cyclonedx-linux-arm" => "cyclonedx" | ||
end | ||
end | ||
if Hardware::CPU.intel? | ||
url "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v%VERSION%/cyclonedx-linux-x64", :using => :nounzip | ||
sha256 "%SHA256SUM_linux-x64%" | ||
|
||
def install | ||
bin.install "cyclonedx-linux-x64" => "cyclonedx" | ||
end | ||
end | ||
end | ||
|
||
test do | ||
system "#{bin}/cyclonedx" "--version" | ||
end | ||
end |
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,29 @@ | ||
#!/bin/bash | ||
set -e | ||
# Purpose: generate a forumla for "CycloneDX-gomod" | ||
|
||
UF_REPO='CycloneDX/cyclonedx-gomod' | ||
UF_VERSION="$1" | ||
|
||
THIS_DIR="$(realpath "$(dirname "$0")" )" | ||
TMP_DIR="$(mktemp -d "$THIS_DIR/.tmp.fu.XXXXXXXX")" | ||
|
||
formula="$(< "$THIS_DIR/template.rb")" | ||
|
||
gh release download \ | ||
"v${UF_VERSION}" \ | ||
--repo "$UF_REPO" \ | ||
--pattern "cyclonedx-gomod_${UF_VERSION}_darwin_*.tar.gz" \ | ||
--pattern "cyclonedx-gomod_${UF_VERSION}_linux_*.tar.gz" \ | ||
--dir "$TMP_DIR" \ | ||
1>&2 | ||
|
||
for _target in 'darwin_amd64' 'darwin_arm64' 'linux_arm64' 'linux_amd64' | ||
do | ||
_sha256sum="$(sha256sum -b "${TMP_DIR}/cyclonedx-gomod_${UF_VERSION}_${_target}.tar.gz" | cut -f1 -d' ')" | ||
formula=${formula//%SHA256SUM_${_target}%/$_sha256sum} | ||
done | ||
|
||
rm -rf "$TMP_DIR" 1>&2 | ||
|
||
echo "${formula//%VERSION%/$UF_VERSION}" |
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,51 @@ | ||
class CyclonedxGomod < Formula | ||
desc "Creates CycloneDX Software Bill of Materials (SBOM) from Go modules." | ||
homepage "https://cyclonedx.org" | ||
version "%VERSION%" | ||
license "Apache-2.0" | ||
|
||
on_macos do | ||
if Hardware::CPU.intel? | ||
url "https://github.com/CycloneDX/cyclonedx-gomod/releases/download/v%VERSION%/cyclonedx-gomod_%VERSION%_darwin_amd64.tar.gz" | ||
sha256 "%SHA256SUM_darwin_amd64%" | ||
|
||
def install | ||
bin.install "cyclonedx-gomod" | ||
end | ||
end | ||
if Hardware::CPU.arm? | ||
url "https://github.com/CycloneDX/cyclonedx-gomod/releases/download/v%VERSION%/cyclonedx-gomod_%VERSION%_darwin_arm64.tar.gz" | ||
sha256 "%SHA256SUM_darwin_arm64%" | ||
|
||
def install | ||
bin.install "cyclonedx-gomod" | ||
end | ||
end | ||
end | ||
|
||
on_linux do | ||
if Hardware::CPU.arm? | ||
url "https://github.com/CycloneDX/cyclonedx-gomod/releases/download/v%VERSION%/cyclonedx-gomod_%VERSION%_linux_arm64.tar.gz" | ||
sha256 "%SHA256SUM_linux_arm64%" | ||
|
||
def install | ||
bin.install "cyclonedx-gomod" | ||
end | ||
end | ||
if Hardware::CPU.intel? | ||
url "https://github.com/CycloneDX/cyclonedx-gomod/releases/download/v%VERSION%/cyclonedx-gomod_%VERSION%_linux_amd64.tar.gz" | ||
sha256 "%SHA256SUM_linux_amd64%" | ||
|
||
def install | ||
bin.install "cyclonedx-gomod" | ||
end | ||
end | ||
end | ||
|
||
depends_on "go" => :optional | ||
depends_on "git" => :optional | ||
|
||
test do | ||
system "#{bin}/cyclonedx-gomod" "version" | ||
end | ||
end |
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,53 @@ | ||
name: Update a formula | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
subject: | ||
description: which formula to update? | ||
required: true | ||
type: choice | ||
options: | ||
- cli | ||
- gomod | ||
version: | ||
description: which version shall be published | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: write # push commits | ||
pull-requests: write # create pullrequests | ||
|
||
jobs: | ||
update: | ||
name: "update formula: ${{ github.event.inputs.subject }} ${{ github.event.inputs.version }}" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
env: | ||
UF_SUBJECT: ${{ github.event.inputs.subject }} | ||
UF_VERSION: ${{ github.event.inputs.version }} | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v4 | ||
- name: Update Formula | ||
run: > | ||
.github/scripts/update-formula/"${UF_SUBJECT}"/gen.sh | ||
"${UF_VERSION}" | ||
> Formula/cyclonedx-"${UF_SUBJECT}".rb | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Commit & Push | ||
run: | | ||
BRANCH_NAME="update-formula/${UF_SUBJECT}-${UF_VERSION}" | ||
git checkout -B "$BRANCH_NAME" | ||
git add -A Formula | ||
git config user.name "[BOT] Formula Updater" | ||
git config user.email "[email protected]" | ||
git commit -m "Update ${UF_SUBJECT}: ${UF_VERSION}" | ||
git push -f --set-upstream origin "$BRANCH_NAME" | ||
- name: Open PullRequest | ||
run: gh pr create --fill-verbose --label "$UF_SUBJECT" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,3 @@ | ||
# all maintainers are default-reviewers of new pull requests. | ||
# see https://github.com/orgs/CycloneDX/teams/maintainers | ||
* @CycloneDX/maintainers |