Skip to content

v0.1.2

v0.1.2 #25

Workflow file for this run

name: Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
name: Build and Release Binaries
runs-on: macos-latest
strategy:
matrix:
target: [x86_64-apple-darwin]
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Build the Binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create Release Asset
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/ecs-exec release/
zip -j release/ecs-exec-${{ matrix.target }}.zip release/ecs-exec*
- name: Generate Checksum
id: generate_checksum
run: |
shasum -a 256 release/ecs-exec-${{ matrix.target }}.zip > release/ecs-exec-${{ matrix.target }}.sha256
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: release/ecs-exec-${{ matrix.target }}.zip # Use explicit path, no wildcards
asset_name: ecs-exec-${{ matrix.target }}.zip
asset_content_type: application/zip
- name: Upload Checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: release/ecs-exec-${{ matrix.target }}.sha256
asset_name: ecs-exec-${{ matrix.target }}.sha256
asset_content_type: text/plain
update-homebrew:
name: Update Homebrew Formula
runs-on: macos-latest
needs: build
strategy:
matrix:
target: [ x86_64-apple-darwin ]
steps:
- name: Checkout Homebrew Tap Repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: kyrylokulyhin/homebrew-cli-tools
token: ${{ secrets.REPO_ACCESS_TOKEN }}
path: homebrew-cli-tools
- name: Download Checksum
run: |
if [ -z "${{ matrix.target }}" ]; then
echo "Target not specified, skipping download"
exit 1
fi
DOWNLOAD_URL="https://github.com/kyrylokulyhin/ecs-exec/releases/download/${{ github.event.release.tag_name }}/ecs-exec-${{ matrix.target }}.sha256"
echo "Downloading checksum from $DOWNLOAD_URL"
curl -L -o ecs-exec-${{ matrix.target }}.sha256 $DOWNLOAD_URL
- name: Check if Formula Exists
run: |
if [ ! -f "homebrew-cli-tools/Formula/ecs-exec.rb" ]; then
echo "Formula file not found!"
exit 1
fi
- name: Update Homebrew Formula
run: |
CHECKSUM=$(awk '{ print $1 }' ecs-exec-${{ matrix.target }}.sha256)
FORMULA_PATH="homebrew-cli-tools/Formula/ecs-exec.rb"
DOWNLOAD_URL="https://github.com/kyrylokulyhin/ecs-exec/releases/download/${{ github.event.release.tag_name }}/ecs-exec-${{ matrix.target }}.zip"
if [ -z "$CHECKSUM" ]; then
echo "Error: SHA256 checksum is empty!"
exit 1
else
echo "SHA256 checksum: $CHECKSUM"
fi
# Replace the URL in the formula
sed -i '' "s|url \".*\"|url \"${DOWNLOAD_URL}\"|" $FORMULA_PATH
# Replace the SHA256 checksum in the formula
sed -i '' "s|sha256 \".*\"|sha256 \"${CHECKSUM}\"|" $FORMULA_PATH
# Replace the version in the formula
sed -i '' "s|version \".*\"|version \"${{ github.event.release.tag_name }}\"|" $FORMULA_PATH
- name: Commit and Push Formula Update
run: |
cd homebrew-cli-tools/
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add Formula/ecs-exec.rb
git commit -m "Update ecs-exec formula to version ${{ github.event.release.tag_name }}"
git push https://kyrylokulyhin:${{ secrets.REPO_ACCESS_TOKEN }}@github.com/kyrylokulyhin/homebrew-cli-tools.git HEAD:main