Skip to content

Commit

Permalink
Merge pull request #7 from fe-lang/christoph/ci-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig authored Sep 11, 2023
2 parents 1d48553 + 2176db1 commit 94ed4dd
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 4 deletions.
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: '*/15 * * * *'

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 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
21 changes: 21 additions & 0 deletions scripts/check-for-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

# 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
26 changes: 26 additions & 0 deletions scripts/get-latest-fe-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

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

# 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
9 changes: 6 additions & 3 deletions scripts/update.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

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

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 +20,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 +38,7 @@ blueprint="class Fe < Formula
bin.install \"fe_amd64\" => \"fe\"
end
end
end"
end
"

echo "$blueprint"

0 comments on commit 94ed4dd

Please sign in to comment.