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

Setup automatic release deployment #12

Open
jnsahaj opened this issue Nov 9, 2024 · 2 comments
Open

Setup automatic release deployment #12

jnsahaj opened this issue Nov 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jnsahaj
Copy link
Owner

jnsahaj commented Nov 9, 2024

The process of deploying a release on homebrew is the following

cargo build --release
cd target/release

# generate release binary
tar -czf lumen.tar.gz lumen

Upload the release binary under a new release on Github

# generate shasum to be used for homebrew
shasum -a 256 lumen.tar.gz 

Inside jnsahaj/homebrew-lumen

  1. Update shasum
  2. Update download URL for the new release
  3. Update version
  4. Push to main

After homebrew deployment, need to deploy new version to cargo

  1. Update Cargo.toml version
  2. Stage and commit Cargo.toml and Cargo.lock files
  3. Run cargo publish
@jnsahaj jnsahaj added enhancement New feature or request good first issue Good for newcomers and removed good first issue Good for newcomers labels Nov 9, 2024
@jmattaa
Copy link
Contributor

jmattaa commented Nov 23, 2024

I've done something similar to my own project I'm using GitHub workflows to automate the changes to be done on the homebrew tap repo using this script:

name: Update Homebrew Tap

on:
  push:
    tags:
      - 'v*' 
  workflow_dispatch: # allow manual trigger

jobs:
  update-tap:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set release version from tag
        run: echo "RELEASE_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV

      - name: Download release artifact
        run: wget https://github.com/jmattaa/laser/archive/${RELEASE_VERSION}.tar.gz -O laser-${RELEASE_VERSION}.tar.gz

      - name: Calculate SHA256 checksum
        id: sha256
        run: echo "SHA256=$(sha256sum laser-${RELEASE_VERSION}.tar.gz | awk '{print $1}')" >> $GITHUB_ENV

      - name: Clone the Homebrew Tap repository
        run: |
          git clone https://github.com/jmattaa/homebrew-laser.git
          cd homebrew-laser
          git checkout main

      - name: Update laser.rb formula
        run: |
          cd homebrew-laser
          sed -i.bak "s|^  url .*|  url \"https://github.com/jmattaa/laser/archive/${RELEASE_VERSION}.tar.gz\"|" laser.rb
          sed -i.bak "s|^  sha256 .*|  sha256 \"${SHA256}\"|" laser.rb
          sed -i.bak "s|^  version .*|  version \"${RELEASE_VERSION}\"|" laser.rb

      - name: Commit and push changes to the Homebrew Tap
        run: |
          cd homebrew-laser
        
          git config --local user.name "github-actions[bot]"
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/jmattaa/homebrew-laser.git

          git add laser.rb
          git commit -m "chore: update laser.rb for ${RELEASE_VERSION}"
          git push origin main

@jnsahaj
Copy link
Owner Author

jnsahaj commented Nov 23, 2024

This is fantastic!
I will probably add this before the next release, and hook up the before/after steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants