From a03dc113993e2df32dea08ed6d69c6f64b93ae78 Mon Sep 17 00:00:00 2001 From: Evgeny Metelkin Date: Wed, 8 Jan 2025 16:43:32 +0200 Subject: [PATCH] add release to homebrew-heta-compiler --- .github/workflows/on-release.yml | 85 +++++++++++++------ {Formula => build-homebrew}/README.md | 0 .../heta-compiler.template.rb | 4 +- index.md | 2 +- 4 files changed, 63 insertions(+), 28 deletions(-) rename {Formula => build-homebrew}/README.md (100%) rename Formula/heta-compiler.rb => build-homebrew/heta-compiler.template.rb (86%) diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml index e89f33f3..2884aeb2 100644 --- a/.github/workflows/on-release.yml +++ b/.github/workflows/on-release.yml @@ -5,7 +5,7 @@ on: types: [created] jobs: - upload-release-asset: + upload-macos-release-asset: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,61 +15,96 @@ jobs: - run: npm ci - name: Build standalone apps run: | - npx pkg . -t linux,macos --compress GZip + npx pkg . -t macos --compress GZip cd ./dist - cp -f heta-compiler-linux heta-compiler - chmod 775 heta-compiler - tar -czvf ./heta-compiler-linux.tar.gz ./heta-compiler - cp -f heta-compiler-macos heta-compiler chmod 775 heta-compiler tar -czvf ./heta-compiler-macos.tar.gz ./heta-compiler cd .. - - name: Create .deb package - run: | - mkdir -p dist/heta-compiler-deb/DEBIAN - cp build-deb/control dist/heta-compiler-deb/DEBIAN/ - mkdir -p dist/heta-compiler-deb/usr/local/bin - cp dist/heta-compiler-linux dist/heta-compiler-deb/usr/local/bin/heta - dpkg-deb --build dist/heta-compiler-deb - - name: Upload Release Asset Linux + - name: Upload Release Asset Macos uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: dist/heta-compiler-linux - asset_name: heta-compiler-linux-x64 + asset_path: dist/heta-compiler + asset_name: heta-compiler-macos-x64 asset_content_type: application/octet-stream - - name: Upload Release Asset Macos + - name: Upload Release TAR.GZ Macos uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: dist/heta-compiler-macos - asset_name: heta-compiler-macos-x64 + asset_path: dist/heta-compiler-macos.tar.gz + asset_name: heta-compiler-macos.tar.gz asset_content_type: application/octet-stream - - name: Upload Release TAR.GZ Linux + - name: Configure SSH + run: | + mkdir -p ~/.ssh + echo "$DEPLOY_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + env: + DEPLOY_KEY: ${{ secrets.DEPLOY_HOMEBREW_HETA_COMPILER }} + + - name: Commit to homebrew-heta-compiler repos + run: | + git clone git@github.com:hetalang/homebrew-heta-compiler.git + cd homebrew-heta-compiler + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + mkdir -p Formula + cp -f ../build-homebrew/heta-compiler.template.rb Formula/heta-compiler.rb # copy the new formula and replace the old one + sed -i "s|\$VERSION|${{ github.event.release.tag_name }}|" Formula/heta-compiler.rb + SHA=$(sha256sum ../dist/heta-compiler-macos.tar.gz | awk '{print $1}') + sed -i "s|\$SHA256|$SHA|" Formula/heta-compiler.rb + git add . + git commit -m "Automated update from source repository based on release ${{ github.event.release.tag_name }}" + git push origin master + upload-linux-release-asset: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.x + - run: npm ci + - name: Build standalone apps + run: | + npx pkg . -t linux --compress GZip + cd ./dist + chmod 775 heta-compiler + tar -czvf ./heta-compiler-linux.tar.gz ./heta-compiler + cd .. + - name: Create .deb package + run: | + mkdir -p dist/heta-compiler-deb/DEBIAN + cp build-deb/control dist/heta-compiler-deb/DEBIAN/ + mkdir -p dist/heta-compiler-deb/usr/local/bin + cp dist/heta-compiler dist/heta-compiler-deb/usr/local/bin/heta + dpkg-deb --build dist/heta-compiler-deb + + - name: Upload Release Asset Linux uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: dist/heta-compiler-linux.tar.gz - asset_name: heta-compiler-linux.tar.gz + asset_path: dist/heta-compiler + asset_name: heta-compiler-linux-x64 asset_content_type: application/octet-stream - - name: Upload Release TAR.GZ Macos + - name: Upload Release TAR.GZ Linux uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: dist/heta-compiler-macos.tar.gz - asset_name: heta-compiler-macos.tar.gz + asset_path: dist/heta-compiler-linux.tar.gz + asset_name: heta-compiler-linux.tar.gz asset_content_type: application/octet-stream - name: Upload Release DEB Linux diff --git a/Formula/README.md b/build-homebrew/README.md similarity index 100% rename from Formula/README.md rename to build-homebrew/README.md diff --git a/Formula/heta-compiler.rb b/build-homebrew/heta-compiler.template.rb similarity index 86% rename from Formula/heta-compiler.rb rename to build-homebrew/heta-compiler.template.rb index b8d5b260..6b859630 100644 --- a/Formula/heta-compiler.rb +++ b/build-homebrew/heta-compiler.template.rb @@ -1,8 +1,8 @@ class HetaCompiler < Formula desc "CLI for Heta Compiler" homepage "https://hetalang.github.io/#/heta-compiler/" - url "https://github.com/hetalang/heta-compiler/releases/download/v0.9.2/heta-compiler-macos.tar.gz" - sha256 "a5ecd974c941d71c20ba71e37dc5e048ac42bb2a2e36147bc363bea315d25293" + url "https://github.com/hetalang/heta-compiler/releases/download/$VERSION/heta-compiler-macos.tar.gz" + sha256 "$SHA256" license "Apache-2.0" def install diff --git a/index.md b/index.md index 4a61a633..0c079510 100644 --- a/index.md +++ b/index.md @@ -89,7 +89,7 @@ rm ~/bin/heta If you have [Homebrew installed](https://brew.sh/), you can install Heta compiler using the following commands: ```bash -brew tap hetalang/heta-compiler https://github.com/hetalang/heta-compiler +brew tap hetalang/heta-compiler brew install heta-compiler ```