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

CI job to autodetect releases and make them available via brew #6

Merged
merged 4 commits into from
Sep 1, 2023
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: cut new release

on:
schedule:
- cron: '*/10 * * * *'
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run first script
run: |
./scripts/check-for-update.sh
id: version_check
- name: Run second script if the versions differ
run: |
./scripts/archive-current-formula.sh
./scripts/update.sh > Formula/fe.rb
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions Bot"
git checkout -b testbranch3
git add .
git commit -m "Added new Release via GitHub Actions"
git push origin main
1 change: 0 additions & 1 deletion Formula/fe.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Fe < Formula
desc "Compiler for the Fe programming language"
homepage "https://github.com/ethereum/fe"
version "0.24.0"

if OS.mac?
url "https://github.com/ethereum/fe/releases/download/v0.24.0/fe_mac"
Expand Down
27 changes: 27 additions & 0 deletions scripts/archive-current-formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Change the working directory to the script's directory
cd $(dirname "$0") || exit

# Path to the input file
input_file="../Formula/fe.rb"

# Extract the version from the input file
version=$(grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' "$input_file" | head -n 1 | sed 's/v//')

# Check if version is not empty
if [ -n "$version" ]; then
# Define the new filename
new_filename="../Formula/fe@${version}.rb"

# Check if the new filename already exists
if [ -e "$new_filename" ]; then
echo "File '$new_filename' already exists."
else
# Rename the file
mv "$input_file" "$new_filename"
echo "File renamed to '$new_filename'."
fi
else
echo "Version not found in the file."
fi
19 changes: 19 additions & 0 deletions scripts/check-for-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Change the working directory to the script's directory
cd $(dirname "$0") || exit

# Run the first script to get the latest FE version
latest_version=$(./get-latest-fe-version.sh)

# Run the second script to get the formula version
formula_version=$(./get-formula-version.sh)

# Compare the versions
if [ "$latest_version" != "$formula_version" ]; then
echo "Versions differ: Latest version is $latest_version, Formula version is $formula_version"
exit 0
else
echo "Versions are the same: $latest_version"
exit 1
fi
10 changes: 10 additions & 0 deletions scripts/get-formula-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Change the working directory to the script's directory
cd $(dirname "$0") || exit

file_path="../Formula/fe.rb"

# Extract version using grep and awk
version=$(grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' "$file_path" | head -n 1 | sed 's/v//')
echo $version
23 changes: 23 additions & 0 deletions scripts/get-latest-fe-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Define your GitHub repository owner and name
repo_owner="ethereum"
repo_name="fe"

# Make the API request and store the response in a variable
response=$(curl -s "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest")

# Check if the request was successful (HTTP status code 200)
if [[ $? -eq 0 ]]; then
# Extract the "name" field from the JSON response
name=$(echo "$response" | jq -r ".name")

# Remove a leading "v" from the name (if present)
name_without_v="${name#v}"

# Print the modified name
echo $name_without_v
else
echo "Failed to fetch latest release."
exit 1
fi
6 changes: 3 additions & 3 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ $# -ne 1 ]; then
# If the script is invoked without version parameter, it will figure out the latest release automatically
version=$(curl -s -L -o /dev/null -w %{url_effective} https://github.com/ethereum/fe/releases/latest | sed 's/.*tag\/v//')
version=$(./get-latest-fe-version.sh)
else
version=$1
fi
Expand All @@ -17,7 +17,6 @@ sha256_mac=$(curl -Ls "$url_mac" | shasum -a 256 | awk '{print $1}')
blueprint="class Fe < Formula
desc \"Compiler for the Fe programming language\"
homepage \"https://github.com/ethereum/fe\"
version \"${version}\"

if OS.mac?
url \"https://github.com/ethereum/fe/releases/download/v${version}/fe_mac\"
Expand All @@ -36,6 +35,7 @@ blueprint="class Fe < Formula
bin.install \"fe_amd64\" => \"fe\"
end
end
end"
end
"

echo "$blueprint"