Skip to content

lol force

lol force #19

Workflow file for this run

name: CI/CD
on:
workflow_dispatch:
push:
branches:
- 'release/**'
- 'master'
pull_request:
branches:
- 'master'
- '**'
types: [opened, synchronize, reopened]
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Toolchain file bug workaround: https://github.com/dtolnay/rust-toolchain/issues/153
- run: rustup component add rustfmt
- name: Run Fmt Check
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: rustup component add clippy
- name: Run clippy
run: cargo clippy -- -D warnings -A clippy::uninlined_format_args
build:
if: |
(github.event_name == 'push' || github.event_name == 'pull_request') &&
github.actor != 'github-actions[bot]' &&
(
!(github.event_name == 'pull_request' &&
startsWith(github.event.pull_request.head.ref, 'release/') &&
github.event.pull_request.base.ref == 'master') ||
(github.event_name == 'pull_request' &&
(contains(github.event.pull_request.head.ref, '/merge') ||
startsWith(github.event.pull_request.head.ref, 'merge')))
) &&
!(github.ref == 'refs/heads/master' &&
github.event_name == 'push' &&
(contains(github.event.head_commit.message, 'Release v') ||
contains(github.event.head_commit.message, 'release/')))
name: ${{ matrix.target }} (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
platform: linux
arch: amd64
- runner: macos-13
target: x86_64-apple-darwin
platform: darwin
arch: amd64
- runner: macos-latest
target: aarch64-apple-darwin
platform: darwin
arch: arm64
- runner: windows-latest
target: x86_64-pc-windows-msvc
platform: win32
arch: amd64
env:
BUILD_TYPE: release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-on-failure: true
- name: Apple M1 setup
if: matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Linux ARM setup
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Install MSVC target
if: matrix.target == 'x86_64-pc-windows-msvc'
run: rustup target add x86_64-pc-windows-msvc
- name: Install OpenSSL development libraries
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update -y
sudo apt-get install -y libssl-dev pkg-config
- name: Setup cross-compilation for pkg-config
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
- name: Extract version name
id: extract_version
shell: bash
run: echo "VERSION_NAME=${GITHUB_REF#refs/heads/release/}" >> $GITHUB_ENV
- name: Install vcpkg on Windows
if: matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
C:\vcpkg\vcpkg integrate install
echo "VCPKG_ROOT=C:\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "C:\vcpkg" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install CMake on Windows
if: matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
choco install cmake --version=3.20.0 --installargs 'ADD_CMAKE_TO_PATH=System'
refreshenv
cmake --version
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install dependencies with vcpkg on Windows
if: matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
C:\vcpkg\vcpkg install openssl:x64-windows-static-md zlib:x64-windows-static-md
- name: Build binaries
working-directory: crates/cli
env:
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
flags=()
if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then
flags+=(--features jemalloc)
fi
[[ "$target" == *windows* ]] && exe=".exe"
if [[ "$target" == *windows* ]]; then
export PATH="$PATH:/c/vcpkg"
echo "CMAKE_TOOLCHAIN_FILE: $CMAKE_TOOLCHAIN_FILE"
ls -l "$CMAKE_TOOLCHAIN_FILE" || echo "Toolchain file not found!"
fi
if [[ "${{ env.BUILD_TYPE }}" == "release" ]]; then
RUST_BACKTRACE=1 CMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN_FILE" cargo build --release --target "$target" "${flags[@]}" -vv
else
RUST_BACKTRACE=1 CMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN_FILE" cargo build --target "$target" "${flags[@]}" -vv
fi
- name: Smoke Test
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
build_type="${{ env.BUILD_TYPE }}"
binary_path="${{ github.workspace }}/target/$target/$build_type/rrelayer_cli"
if [[ "$target" == *windows* ]]; then
binary_path+=".exe"
fi
echo "Running smoke test for $binary_path"
"$binary_path" --version
"$binary_path" help
- name: Archive binaries
id: artifacts
if: startsWith(github.ref, 'refs/heads/release/')
env:
PLATFORM_NAME: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
ARCH: ${{ matrix.arch }}
VERSION_NAME: ${{ env.VERSION_NAME }}
shell: bash
run: |
set -eo pipefail
BUILD_DIR="${{ github.workspace }}/target/${TARGET}/${{ env.BUILD_TYPE }}"
CLI_BINARY_NAME="rrelayer_cli"
[[ "$PLATFORM_NAME" == "win32" ]] && CLI_BINARY_NAME="rrelayer_cli.exe"
# Create a temporary staging directory for creating the archive
STAGING_DIR="staging"
mkdir -p "$STAGING_DIR"
# Copy binaries to the staging directory
echo "Copying $BUILD_DIR/$CLI_BINARY_NAME to $STAGING_DIR/"
cp "$BUILD_DIR/$CLI_BINARY_NAME" "$STAGING_DIR/"
# Create the final archive
if [ "$PLATFORM_NAME" == "linux" ] || [ "$PLATFORM_NAME" == "darwin" ]; then
FILE_NAME="rrelayer_${PLATFORM_NAME}-${ARCH}.tar.gz"
tar -czvf "$FILE_NAME" -C "$STAGING_DIR" .
else
FILE_NAME="rrelayer_${PLATFORM_NAME}-${ARCH}.zip"
(cd "$STAGING_DIR" && 7z a -tzip "${{ github.workspace }}/$FILE_NAME" .)
fi
echo "Created archive: $FILE_NAME"
echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
- name: Run tests
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
cargo test --exclude rust-sdk-playground --workspace --release --target "$target"
- name: Upload artifact
if: startsWith(github.ref, 'refs/heads/release/')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.file_name }}
create_pr:
name: Create Release PR
runs-on: ubuntu-22.04
needs: build
if: |
github.actor != 'github-actions[bot]' &&
startsWith(github.ref, 'refs/heads/release/')
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Extract version from branch name
shell: bash
run: |
VERSION=${GITHUB_REF#refs/heads/release/}
echo "VERSION_NAME=$VERSION" >> $GITHUB_ENV
- name: Update Cargo.toml versions
shell: bash
run: |
sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/cli/Cargo.toml
sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/core/Cargo.toml
sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/sdk/Cargo.toml
sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' Cargo.toml
# Temporarily commented out changelog update for release process
# - name: Update Changelog
# shell: bash
# run: |
# CHANGELOG_FILE="documentation/rrelayer/docs/pages/changelog.mdx"
# DAY=$(date '+%d' | sed 's/^0*//')
# MONTH=$(date '+%B')
# YEAR=$(date '+%Y')
#
# # Add ordinal suffix
# case $DAY in
# 1|21|31) SUFFIX="st";;
# 2|22) SUFFIX="nd";;
# 3|23) SUFFIX="rd";;
# *) SUFFIX="th";;
# esac
#
# DATE="$DAY$SUFFIX $MONTH $YEAR"
#
# echo "Updating changelog for version ${{ env.VERSION_NAME }}"
#
# # Create changelog if it doesn't exist
# if [[ ! -f "$CHANGELOG_FILE" ]]; then
# cat > "$CHANGELOG_FILE" << EOF
# # Changelog
#
# ## Changes Not Deployed
# -------------------------------------------------
#
# ### Features
# -------------------------------------------------
#
# ### Bug fixes
# -------------------------------------------------
#
# ### Breaking changes
# -------------------------------------------------
#
# ## Releases
# -------------------------------------------------
#
# all release branches are deployed through \`release/VERSION_NUMBER\` branches
#
# EOF
# fi
#
# # Create a temporary file to work with
# cp "$CHANGELOG_FILE" changelog_temp.md
#
# # Extract just the bug fixes line directly from Changes Not Deployed section
# BUG_FIXES=$(sed -n '/^## Changes Not Deployed/,/^## Releases/p' changelog_temp.md | grep "^- fix:" | head -5)
#
# # Use the simple extraction for now
# FEATURES=""
# BUG_FIXES="$BUG_FIXES"
# BREAKING_CHANGES=""
#
# # Save the extracted content for PR creation
# {
# echo "### Changes in this release:"
# echo "-------------------------------------------------"
# echo "### Features"
# echo "-------------------------------------------------"
# if [[ -n "$FEATURES" ]]; then
# echo "$FEATURES"
# fi
# echo ""
# echo "### Bug fixes"
# echo "-------------------------------------------------"
# if [[ -n "$BUG_FIXES" ]]; then
# echo "$BUG_FIXES"
# fi
# echo ""
# echo "### Breaking changes"
# echo "-------------------------------------------------"
# if [[ -n "$BREAKING_CHANGES" ]]; then
# echo "$BREAKING_CHANGES"
# fi
# } > pr_body_content.txt
#
# # Save to environment variable
# echo "PR_BODY_CONTENT<<EOF" >> $GITHUB_ENV
# cat pr_body_content.txt >> $GITHUB_ENV
# echo "EOF" >> $GITHUB_ENV
#
# # Create new release entry
# cat > new_release.txt << EOF
# # ${{ env.VERSION_NAME }}-beta - $DATE
#
# github branch - https://github.com/joshstevens19/rrelayer/tree/release/${{ env.VERSION_NAME }}
#
# - linux binary - https://github.com/joshstevens19/rrelayer/releases/download/v${{ env.VERSION_NAME }}/rrelayer_linux-amd64.tar.gz
# - mac apple silicon binary - https://github.com/joshstevens19/rrelayer/releases/download/v${{ env.VERSION_NAME }}/rrelayer_darwin-arm64.tar.gz
# - mac apple intel binary - https://github.com/joshstevens19/rrelayer/releases/download/v${{ env.VERSION_NAME }}/rrelayer_darwin-amd64.tar.gz
# - windows binary - https://github.com/joshstevens19/rrelayer/releases/download/v${{ env.VERSION_NAME }}/rrelayer_win32-amd64.zip
# EOF
#
# # Add sections if they have content
# if [[ -n "$FEATURES" && "$FEATURES" =~ [^[:space:]] ]]; then
# echo "" >> new_release.txt
# echo "### Features" >> new_release.txt
# echo "-------------------------------------------------" >> new_release.txt
# echo "$FEATURES" >> new_release.txt
# fi
#
# if [[ -n "$BUG_FIXES" && "$BUG_FIXES" =~ [^[:space:]] ]]; then
# echo "" >> new_release.txt
# echo "### Bug fixes" >> new_release.txt
# echo "-------------------------------------------------" >> new_release.txt
# echo "$BUG_FIXES" >> new_release.txt
# fi
#
# if [[ -n "$BREAKING_CHANGES" && "$BREAKING_CHANGES" =~ [^[:space:]] ]]; then
# echo "" >> new_release.txt
# echo "### Breaking changes" >> new_release.txt
# echo "-------------------------------------------------" >> new_release.txt
# echo "$BREAKING_CHANGES" >> new_release.txt
# fi
#
# # Get existing releases (everything after "## Releases")
# EXISTING_RELEASES=$(awk '/^## Releases/,0' changelog_temp.md | tail -n +5)
#
# # Create new changelog
# cat > "$CHANGELOG_FILE" << EOF
# # Changelog
#
# ## Changes Not Deployed
# -------------------------------------------------
#
# ### Features
# -------------------------------------------------
#
# ### Bug fixes
# -------------------------------------------------
#
# ### Breaking changes
# -------------------------------------------------
#
# ## Releases
# -------------------------------------------------
#
# all release branches are deployed through \`release/VERSION_NUMBER\` branches
#
# $(cat new_release.txt)
#
# $EXISTING_RELEASES
# EOF
#
# # Clean up temporary files
# rm -f changelog_temp.md new_release.txt pr_body_content.txt
#
# echo "Changelog updated successfully"
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add crates/cli/Cargo.toml crates/core/Cargo.toml crates/sdk/Cargo.toml Cargo.toml
git commit -m "Release v${{ env.VERSION_NAME }}"
git push origin release/${{ env.VERSION_NAME }}
- name: Check if PR already exists
id: check_pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_EXISTS=$(gh pr list --base master --head release/${{ env.VERSION_NAME }} --json number --jq length)
if [ "$PR_EXISTS" -gt 0 ]; then
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "PR already exists, skipping creation"
else
echo "pr_exists=false" >> $GITHUB_OUTPUT
echo "No PR exists, will create one"
fi
- name: Create Pull Request
if: steps.check_pr.outputs.pr_exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "Release v${{ env.VERSION_NAME }}" \
--body "## Release v${{ env.VERSION_NAME }}
This PR contains:
- ✅ Version bump to ${{ env.VERSION_NAME }}
- ✅ Changelog updated with release notes
- ✅ Ready for release
**Merging this PR will automatically create a GitHub Release with binaries.**
${{ env.PR_BODY_CONTENT }}" \
--base master \
--head release/${{ env.VERSION_NAME }}
release_build:
name: Build Release Binaries
runs-on: ${{ matrix.runner }}
if: |
github.actor != 'github-actions[bot]' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
platform: linux
arch: amd64
- runner: macos-13
target: x86_64-apple-darwin
platform: darwin
arch: amd64
- runner: macos-latest
target: aarch64-apple-darwin
platform: darwin
arch: arm64
- runner: windows-latest
target: x86_64-pc-windows-msvc
platform: win32
arch: amd64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if this is a release commit and extract version
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "=== DEBUG: Checking recent commits ==="
git log --oneline -10 --pretty=format:"%H %s"
echo ""
echo "=== DEBUG: Checking for release pattern ==="
# Check the most recent commit (HEAD) for release pattern
RECENT_COMMIT_MSG=$(git log --oneline -1 --pretty=format:"%s")
echo "Most recent commit: '$RECENT_COMMIT_MSG'"
# Try to extract version from Release v pattern (including PR number)
VERSION_FROM_RELEASE=$(echo "$RECENT_COMMIT_MSG" | grep -o 'Release v[0-9]*\.[0-9]*\.[0-9]*' | sed 's/Release v//' || echo "")
echo "VERSION_FROM_RELEASE: '$VERSION_FROM_RELEASE'"
if [[ -n "$VERSION_FROM_RELEASE" ]]; then
echo "VERSION_NAME=$VERSION_FROM_RELEASE" >> $GITHUB_ENV
echo "is_release=true" >> $GITHUB_OUTPUT
echo "Found release from commit title: Release v$VERSION_FROM_RELEASE"
else
echo "Not a release commit"
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- name: Skip if not a release
if: steps.check_release.outputs.is_release != 'true'
run: |
echo "Skipping release build - not a release commit"
exit 0
- name: Checkout release branch
if: steps.check_release.outputs.is_release == 'true'
uses: actions/checkout@v4
with:
ref: release/${{ env.VERSION_NAME }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
if: steps.check_release.outputs.is_release == 'true'
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
if: steps.check_release.outputs.is_release == 'true'
with:
key: ${{ matrix.target }}
cache-on-failure: true
- name: Apple M1 setup
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Install MSVC target
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'x86_64-pc-windows-msvc'
run: rustup target add x86_64-pc-windows-msvc
- name: Install OpenSSL development libraries
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update -y
sudo apt-get install -y libssl-dev pkg-config
- name: Install vcpkg on Windows
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
C:\vcpkg\vcpkg integrate install
echo "VCPKG_ROOT=C:\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "C:\vcpkg" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install CMake on Windows
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
choco install cmake --version=3.20.0 --installargs 'ADD_CMAKE_TO_PATH=System'
refreshenv
cmake --version
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install dependencies with vcpkg on Windows
if: steps.check_release.outputs.is_release == 'true' && matrix.target == 'x86_64-pc-windows-msvc'
shell: pwsh
run: |
C:\vcpkg\vcpkg install openssl:x64-windows-static-md zlib:x64-windows-static-md
- name: Build binaries
if: steps.check_release.outputs.is_release == 'true'
working-directory: crates/cli
env:
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then
flags+=(--features jemalloc)
fi
if [[ "$target" == *windows* ]]; then
export PATH="$PATH:/c/vcpkg"
echo "CMAKE_TOOLCHAIN_FILE: $CMAKE_TOOLCHAIN_FILE"
ls -l "$CMAKE_TOOLCHAIN_FILE" || echo "Toolchain file not found!"
fi
RUST_BACKTRACE=1 CMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN_FILE" cargo build --release --target "$target" -vv
- name: Smoke Test
if: steps.check_release.outputs.is_release == 'true'
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
binary_path="${{ github.workspace }}/target/$target/release/rrelayer_cli"
if [[ "$target" == *windows* ]]; then
binary_path+=".exe"
fi
echo "Running smoke test for $binary_path"
"$binary_path" --version
"$binary_path" help
- name: Archive binaries
if: steps.check_release.outputs.is_release == 'true'
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
ARCH: ${{ matrix.arch }}
VERSION_NAME: ${{ env.VERSION_NAME }}
shell: bash
run: |
set -eo pipefail
BUILD_DIR="${{ github.workspace }}/target/${TARGET}/release"
CLI_BINARY_NAME="rrelayer_cli"
[[ "$PLATFORM_NAME" == "win32" ]] && CLI_BINARY_NAME="rrelayer_cli.exe"
# Create a temporary staging directory for creating the archive
STAGING_DIR="staging"
mkdir -p "$STAGING_DIR"
# Copy binaries to the staging directory
echo "Copying $BUILD_DIR/$CLI_BINARY_NAME to $STAGING_DIR/"
cp "$BUILD_DIR/$CLI_BINARY_NAME" "$STAGING_DIR/"
# Create the final archive
if [ "$PLATFORM_NAME" == "linux" ] || [ "$PLATFORM_NAME" == "darwin" ]; then
FILE_NAME="rrelayer_${PLATFORM_NAME}-${ARCH}.tar.gz"
tar -czvf "$FILE_NAME" -C "$STAGING_DIR" .
else
FILE_NAME="rrelayer_${PLATFORM_NAME}-${ARCH}.zip"
(cd "$STAGING_DIR" && 7z a -tzip "${{ github.workspace }}/$FILE_NAME" .)
fi
echo "Created archive: $FILE_NAME"
echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
- name: Upload artifact
if: steps.check_release.outputs.is_release == 'true'
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.file_name }}
release:
name: Create GitHub Release
runs-on: ubuntu-22.04
needs: release_build
if: |
github.actor != 'github-actions[bot]' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if this is a release commit and extract version
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "=== DEBUG: Checking recent commits ==="
git log --oneline -10 --pretty=format:"%H %s"
echo ""
echo "=== DEBUG: Checking for release pattern ==="
# Check the most recent commit (HEAD) for release pattern
RECENT_COMMIT_MSG=$(git log --oneline -1 --pretty=format:"%s")
echo "Most recent commit: '$RECENT_COMMIT_MSG'"
# Try to extract version from Release v pattern (including PR number)
VERSION_FROM_RELEASE=$(echo "$RECENT_COMMIT_MSG" | grep -o 'Release v[0-9]*\.[0-9]*\.[0-9]*' | sed 's/Release v//' || echo "")
echo "VERSION_FROM_RELEASE: '$VERSION_FROM_RELEASE'"
if [[ -n "$VERSION_FROM_RELEASE" ]]; then
echo "VERSION_NAME=$VERSION_FROM_RELEASE" >> $GITHUB_ENV
echo "is_release=true" >> $GITHUB_OUTPUT
echo "Found release from commit title: Release v$VERSION_FROM_RELEASE"
else
echo "Not a release commit"
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- name: Skip if not a release
if: steps.check_release.outputs.is_release != 'true'
run: |
echo "Skipping release creation - not a release commit"
exit 0
- name: Download release artifacts
if: steps.check_release.outputs.is_release == 'true'
uses: actions/download-artifact@v4
with:
path: ./release-artifacts
- name: Display structure of downloaded files
if: steps.check_release.outputs.is_release == 'true'
run: ls -la ./release-artifacts/
- name: Create GitHub Release
if: steps.check_release.outputs.is_release == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION_NAME }}
release_name: Release v${{ env.VERSION_NAME }}
draft: false
prerelease: false
body: |
Release v${{ env.VERSION_NAME }}
## Installation
```bash
# Latest version
curl -sSfL https://docs.rrelayer.com/install.sh | bash
# Specific version
curl -sSfL https://docs.rrelayer.com/install.sh | bash -s -- --version ${{ env.VERSION_NAME }}
```
continue-on-error: true
- name: Upload Release Assets
if: steps.check_release.outputs.is_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for platform_dir in ./release-artifacts/*/; do
for file in "$platform_dir"*; do
if [[ -f "$file" ]]; then
filename=$(basename "$file")
echo "Uploading $filename"
gh release upload v${{ env.VERSION_NAME }} "$file" --clobber
fi
done
done