Skip to content

Fix redirects on compound commands and negation handling #13

Fix redirects on compound commands and negation handling

Fix redirects on compound commands and negation handling #13

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux x86_64
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- name: macOS ARM64
target: aarch64-apple-darwin
os: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libncurses-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Set version from tag
run: |
# Extract version from tag (e.g., v0.1.0 -> 0.1.0)
VERSION="${GITHUB_REF_NAME#v}"
echo "Setting version to $VERSION"
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" Cargo.toml
rm -f Cargo.toml.bak
grep "^version" Cargo.toml
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test --release -- --test-threads=1
- name: Package
shell: bash
run: |
cd target/release
tar czvf ../../bash-ast-${{ github.ref_name }}-${{ matrix.target }}.tar.gz bash-ast
cd ../..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bash-ast-${{ matrix.target }}
path: bash-ast-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.tar.gz
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
homebrew:
name: Update Homebrew Formula
needs: release
runs-on: ubuntu-latest
# Skip for prereleases
if: ${{ !contains(github.ref_name, '-') }}
steps:
- name: Checkout bash-ast
uses: actions/checkout@v4
- name: Get release info
id: release_info
run: |
# Get the tag name (e.g., v0.1.0)
TAG="${{ github.ref_name }}"
# Get the full commit SHA for this tag
REVISION="${{ github.sha }}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "revision=${REVISION}" >> $GITHUB_OUTPUT
- name: Generate updated formula
run: |
# Extract version number without 'v' prefix for Homebrew
TAG="${{ steps.release_info.outputs.tag }}"
VERSION="${TAG#v}"
# Update the formula with the new version and revision
sed -i \
-e "s/VERSION_TAG_PLACEHOLDER/${TAG}/" \
-e "s/REVISION_PLACEHOLDER/${{ steps.release_info.outputs.revision }}/" \
Formula/bash-ast.rb
echo "Updated formula:"
cat Formula/bash-ast.rb
- name: Checkout homebrew-taps
uses: actions/checkout@v4
with:
repository: cv/homebrew-taps
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-taps
- name: Update formula in tap
run: |
mkdir -p homebrew-taps/Formula
cp Formula/bash-ast.rb homebrew-taps/Formula/
cd homebrew-taps
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/bash-ast.rb
git diff --staged --quiet || git commit -m "bash-ast ${{ steps.release_info.outputs.tag }}"
git push