diff --git a/.github/workflows/tembo_release.yml b/.github/workflows/tembo_release.yml index 6b3b20c07..3697f2ab6 100644 --- a/.github/workflows/tembo_release.yml +++ b/.github/workflows/tembo_release.yml @@ -5,13 +5,15 @@ permissions: on: push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' + branches: + - bump-homebrew-formula + paths: + - 'tembo-cli/Cargo.toml' jobs: - cargo_build: - name: Cargo build + gh_release: + name: Github Release strategy: fail-fast: false matrix: @@ -39,6 +41,11 @@ jobs: os: windows-latest executable: tembo.exe runs-on: ${{ matrix.os }} + outputs: + version: ${{ steps.cli_version_mac.outputs.version }} + release_version: ${{ steps.set_release_version.outputs.release_version }} + sha_x86_64: ${{ steps.fetch_sha256.outputs.sha_x86_64 }} + sha_aarch64: ${{ steps.fetch_sha256.outputs.sha_aarch64 }} container: image: ${{ matrix.container }} steps: @@ -63,14 +70,29 @@ jobs: tar -czvf tembo.tar.gz ${{ matrix.executable }} git config --global --add safe.directory '*' + - name: Fetch sha256 + working-directory: ./tembo-cli + id: fetch_sha256 + run: | + sha_256=$(shasum -a 256 target/${{ matrix.target }}/release/tembo.tar.gz | cut -d" " -f 1) + if [[ ${{ matrix.target }} == "x86_64-apple-darwin" ]] + then + echo "sha_x86_64=$sha_256" >> $GITHUB_OUTPUT + elif [[ ${{ matrix.target }} == "aarch64-apple-darwin" ]] + echo "sha_aarch64=$sha_256" >> $GITHUB_OUTPUT + fi + if: runner.os == 'macOS' + # TODO: Figure out a better way to fetch version for mac & linux - name: CLI version Mac working-directory: ./tembo-cli id: cli_version_mac run: | cargo install cargo-get - TEMBO_CLI_NAME=$(cargo-get package.name)-$(cargo-get package.version) + VERSION=$(cargo-get package.version) + TEMBO_CLI_NAME=$(cargo-get package.name)-$VERSION echo "TEMBO_CLI_NAME=$TEMBO_CLI_NAME" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_OUTPUT if: runner.os == 'macOS' - name: CLI version Linux @@ -100,11 +122,77 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + - name: set env non-windows + id: set_release_version + run: | + RELEASE_VERSION=$(date +'%Y.%m.%d') + echo "NOW=$RELEASE_VERSION" >> $GITHUB_ENV + echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT + if: runner.os != 'Windows' + + - name: set env windows + run: echo "NOW=$(date +'%Y.%m.%d')" >> $env:GITHUB_ENV + if: runner.os == 'Windows' + - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: tembo-cli/target/${{ matrix.target }}/release/tembo.tar.gz asset_name: ${{ env.TEMBO_CLI_NAME }}-${{ matrix.asset_name }}.tar.gz - tag: ${{ github.ref }} + prerelease: true + tag: ${{ env.NOW }} body: ${{ steps.changelog.outputs.changelog }} + + post_gh_release: + runs-on: macos-latest + needs: gh_release + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + repository: tembo-io/homebrew-tembo + ssh-key: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }} + path: homebrew-tembo + - name: Git commit and push to remote + shell: bash + run: | + set -xe + cd homebrew-tembo + git config --global user.name "coredb-service-user" + git config --global user.email "admin+github@coredb.io" + git fetch origin test-bump && git checkout test-bump || git checkout -b test-bump + - name: Replace version + shell: bash + run: | + set -xe + cd homebrew-tembo + sed -E -i '' 's/version ".*/version "${{needs.gh_release.outputs.version}}"/g' tembo-cli.rb + - name: Replace release_version + shell: bash + run: | + set -xe + cd homebrew-tembo + sed -E -i '' 's/release_version =.*/release_version = "${{needs.gh_release.outputs.release_version}}"/g' tembo-cli.rb + - name: Replace sha_x86_64 + shell: bash + run: | + set -xe + cd homebrew-tembo + sed -E -i '' 's/sha256.*/sha256 "${{needs.gh_release.outputs.sha_x86_64}}"/g' tembo-cli.rb + - name: Replace sha_aarch_64 + shell: bash + run: | + set -xe + cd homebrew-tembo + sed -E -i '' '1,/sha256.*/ s/sha256.*/sha256 "${{needs.gh_release.outputs.sha_aarch_64}}"/g' tembo-cli.rb + - name: Git commit and push to remote + shell: bash + run: | + set -xe + cd homebrew-tembo + git add --all + # debugging + git diff HEAD + git commit -m "Update from tembo-io/tembo: ${{ inputs.version }}" + git push origin test-bump