Skip to content

Commit

Permalink
Adding support to publish sui to chocolatey
Browse files Browse the repository at this point in the history
  • Loading branch information
ebmifa committed Jan 24, 2024
1 parent 7c9a8cc commit 3893a4c
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 111 deletions.
246 changes: 135 additions & 111 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ jobs:
timeout-minutes: 80
strategy:
matrix:
os: [ windows-ghcloud, ubuntu-ghcloud, macos-latest-xl, macos-arm64-self-hosted ]
# os: [ windows-ghcloud, ubuntu-ghcloud, macos-latest-xl, macos-arm64-self-hosted ]
os: [ windows-ghcloud ]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -75,18 +76,18 @@ jobs:
export os_type="${system_os}-${arch}"
echo "os_type=${system_os}-${arch}" >> $GITHUB_ENV
- name: Check if archives of binaries have already been built
continue-on-error: true
shell: bash
run: |
echo "s3_archive_exist=$(curl -Is https://sui-releases.s3.us-east-1.amazonaws.com/releases/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz | head -n 1 | grep '200 OK')" >> $GITHUB_ENV
# - name: Check if archives of binaries have already been built
# continue-on-error: true
# shell: bash
# run: |
# echo "s3_archive_exist=$(curl -Is https://sui-releases.s3.us-east-1.amazonaws.com/releases/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz | head -n 1 | grep '200 OK')" >> $GITHUB_ENV

- name: Download archive, if it exists
if: ${{ env.s3_archive_exist != '' }}
shell: bash
run: |
mkdir -p ./target/release
aws s3 cp s3://sui-releases/releases/sui-${{ env.sui_tag }}-${os_type}.tgz ./target/release/sui-${{ env.sui_tag }}-${os_type}.tgz
# - name: Download archive, if it exists
# if: ${{ env.s3_archive_exist != '' }}
# shell: bash
# run: |
# mkdir -p ./target/release
# aws s3 cp s3://sui-releases/releases/sui-${{ env.sui_tag }}-${os_type}.tgz ./target/release/sui-${{ env.sui_tag }}-${os_type}.tgz

- name: Setup caching
if: ${{ env.s3_archive_exist == '' }}
Expand Down Expand Up @@ -124,8 +125,9 @@ jobs:
if: ${{ env.s3_archive_exist == '' }}
shell: bash
run: |
[ -f ~/.cargo/env ] && source ~/.cargo/env ; cargo build --release
cd external-crates/move && cargo build -p move-analyzer --release
# [ -f ~/.cargo/env ] && source ~/.cargo/env ; cargo build --release
# cd external-crates/move && cargo build -p move-analyzer --release
[ -f ~/.cargo/env ] && source ~/.cargo/env ; cargo build --bin sui --release
- name: Rename binaries for ${{ matrix.os }}
if: ${{ matrix.os != 'windows-ghcloud' && env.s3_archive_exist == '' }}
Expand All @@ -146,115 +148,137 @@ jobs:
if: ${{ matrix.os == 'windows-ghcloud' && env.s3_archive_exist == '' }}
shell: bash
run: |
[ -f ./target/release/sui.exe ] && mv ./target/release/sui.exe ./target/release/sui-${os_type}.exe
[ -f ./target/release/sui-node.exe ] && mv ./target/release/sui-node.exe ./target/release/sui-node-${os_type}.exe
[ -f ./target/release/sui-tool.exe ] && mv ./target/release/sui-tool.exe ./target/release/sui-tool-${os_type}.exe
[ -f ./target/release/sui-faucet.exe ] && mv ./target/release/sui-faucet.exe ./target/release/sui-faucet-${os_type}.exe
[ -f ./target/release/sui-test-validator.exe ] && mv ./target/release/sui-test-validator.exe ./target/release/sui-test-validator-${os_type}.exe
[ -f ./target/release/sui-indexer.exe ] && mv ./target/release/sui-indexer.exe ./target/release/sui-indexer-${os_type}.exe
[ -f ./target/release/sui-data-ingestion.exe ] && mv ./target/release/sui-data-ingestion.exe ./target/release/sui-data-ingestion-${os_type}.exe
[ -f ./external-crates/move/target/release/move-analyzer.exe ] && mv ./external-crates/move/target/release/move-analyzer.exe ./external-crates/move/target/release/move-analyzer-${os_type}.exe
[ -f ./target/release/sui.exe ] && cp ./target/release/sui.exe ./target/release/sui-${os_type}.exe
# [ -f ./target/release/sui-node.exe ] && mv ./target/release/sui-node.exe ./target/release/sui-node-${os_type}.exe
# [ -f ./target/release/sui-tool.exe ] && mv ./target/release/sui-tool.exe ./target/release/sui-tool-${os_type}.exe
# [ -f ./target/release/sui-faucet.exe ] && mv ./target/release/sui-faucet.exe ./target/release/sui-faucet-${os_type}.exe
# [ -f ./target/release/sui-test-validator.exe ] && mv ./target/release/sui-test-validator.exe ./target/release/sui-test-validator-${os_type}.exe
# [ -f ./target/release/sui-indexer.exe ] && mv ./target/release/sui-indexer.exe ./target/release/sui-indexer-${os_type}.exe
# [ -f ./target/release/sui-data-ingestion.exe ] && mv ./target/release/sui-data-ingestion.exe ./target/release/sui-data-ingestion-${os_type}.exe
# [ -f ./external-crates/move/target/release/move-analyzer.exe ] && mv ./external-crates/move/target/release/move-analyzer.exe ./external-crates/move/target/release/move-analyzer-${os_type}.exe
tar -cvzf ./target/release/sui-${{ env.sui_tag }}-${os_type}.tgz ./target/release/sui*-${os_type}* ./external-crates/move/target/release/move-analyzer-${os_type}.exe
[[ ${{ env.sui_tag }} == *"mainnet"* ]] && aws s3 cp ./target/release/sui-${{ env.sui_tag }}-${os_type}.tgz s3://sui-releases/releases/sui-${{ env.sui_tag }}-${os_type}.tgz || true
# [[ ${{ env.sui_tag }} == *"mainnet"* ]] && aws s3 cp ./target/release/sui-${{ env.sui_tag }}-${os_type}.tgz s3://sui-releases/releases/sui-${{ env.sui_tag }}-${os_type}.tgz || true
- name: "Publish Windows sui binary to Chocolately"
if: ${{ matrix.os == 'windows-ghcloud' && env.s3_archive_exist == '' && contains( env.sui_tag, 'mainnet') }}
working-directory: ./chocolatey
shell: bash
run: |
echo "sui_version=$(echo ${{ env.sui_tag }} | sed s/'mainnet-v'//)" >> $GITHUB_ENV
choco install checksum
echo "sui_sha=$(checksum -t sha256 ./target/release/sui.exe)" >> $GITHUB_ENV
- name: Upload release artifacts for ${{ matrix.os }} platform
uses: actions/upload-artifact@v3
with:
name: sui-binaries-${{ matrix.os }}
if-no-files-found: error
path: |
./target/release/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz
cat <<EOF >>VERIFICATION.txt
Sui Binary verification steps
1. Go to https://github.com/MystenLabs/sui/releases/download/${{ env.sui_tag }}/sui-${{ env.sui_tag }}-windows-x86_64.tgz
2. Extract sui-windows-x86_64.exe
3. checksum.exe -t sha256 sui-windows-x86_64.exe: ${{ env.sui_sha }}
- name: Publish binaries for ${{ env.sui_tag }} release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.sui_tag }}
files: |
./target/release/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz
File 'LICENSE.txt' is obtained from: https://github.com/MystenLabs/sui/blob/main/LICENSE
EOF
update-homebrew-formula:
name: Push binaries to homebrew
needs: release-build
runs-on: ubuntu-latest
if: ${{ contains( inputs.sui_tag, 'mainnet') || contains( github.ref, 'mainnet') }}
steps:
- name: Clean up tag name ${{ env.TAG_NAME }}
shell: bash
run: |
echo "sui_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'//)" >> $GITHUB_ENV
choco pack --version ${{ env.sui_version }} configuration=release
choco apikey --api-key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/
choco push sui.${{ env.sui_version }}.nupkg --source https://push.chocolatey.org/
# Checkout MystenLabs/homebrew-tap
- name: Checkout Target Repository
uses: actions/checkout@v3
with:
repository: MystenLabs/homebrew-tap
# @john's PAT, needs to be rotated jan 5 2024
token: ${{ secrets.HOMEBREW_TAP_REPO_READ_WRITE }}
ref: main
fetch-depth: 0
# - name: Upload release artifacts for ${{ matrix.os }} platform
# uses: actions/upload-artifact@v3
# with:
# name: sui-binaries-${{ matrix.os }}
# if-no-files-found: error
# path: |
# ./target/release/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz

# Download all artifacts from the previous job
- name: Download all artifacts
uses: actions/download-artifact@v2
# - name: Publish binaries for ${{ env.sui_tag }} release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ env.sui_tag }}
# files: |
# ./target/release/sui-${{ env.sui_tag }}-${{ env.os_type }}.tgz

- name: Fetch Ubuntu x86_64 Binary and Compute SHA256
shell: bash
run: |
echo "sha256_ubuntu_release=$(sha256sum sui-binaries-ubuntu-ghcloud/sui-${{ env.sui_tag }}-ubuntu-x86_64.tgz | awk '{print $1}')" >> $GITHUB_ENV
echo "sha256_macos_x86_release=$(sha256sum sui-binaries-macos-latest-xl/sui-${{ env.sui_tag }}-macos-x86_64.tgz | awk '{print $1}')" >> $GITHUB_ENV
echo "sha256_macos_arm_release=$(sha256sum sui-binaries-macos-arm64-self-hosted/sui-${{ env.sui_tag }}-macos-arm64.tgz | awk '{print $1}' )" >> $GITHUB_ENV
# update-homebrew-formula:
# name: Push binaries to homebrew
# needs: release-build
# runs-on: ubuntu-latest
# if: ${{ contains( inputs.sui_tag, 'mainnet') || contains( github.ref, 'mainnet') }}
# steps:
# - name: Clean up tag name ${{ env.TAG_NAME }}
# shell: bash
# run: |
# echo "sui_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'//)" >> $GITHUB_ENV

# # Checkout MystenLabs/homebrew-tap
# - name: Checkout Target Repository
# uses: actions/checkout@v3
# with:
# repository: MystenLabs/homebrew-tap
# # @john's PAT, needs to be rotated jan 5 2024
# token: ${{ secrets.HOMEBREW_TAP_REPO_READ_WRITE }}
# ref: main
# fetch-depth: 0

# # Download all artifacts from the previous job
# - name: Download all artifacts
# uses: actions/download-artifact@v2

# - name: Fetch Ubuntu x86_64 Binary and Compute SHA256
# shell: bash
# run: |
# echo "sha256_ubuntu_release=$(sha256sum sui-binaries-ubuntu-ghcloud/sui-${{ env.sui_tag }}-ubuntu-x86_64.tgz | awk '{print $1}')" >> $GITHUB_ENV
# echo "sha256_macos_x86_release=$(sha256sum sui-binaries-macos-latest-xl/sui-${{ env.sui_tag }}-macos-x86_64.tgz | awk '{print $1}')" >> $GITHUB_ENV
# echo "sha256_macos_arm_release=$(sha256sum sui-binaries-macos-arm64-self-hosted/sui-${{ env.sui_tag }}-macos-arm64.tgz | awk '{print $1}' )" >> $GITHUB_ENV

# Install Jinja2 for templating
- name: Install Jinja2
run: pip install jinja2
# # Install Jinja2 for templating
# - name: Install Jinja2
# run: pip install jinja2

- name: Apply Jinja2 Template and Update Formula
run: |
python3 - <<EOF
import jinja2
import os
# - name: Apply Jinja2 Template and Update Formula
# run: |
# python3 - <<EOF
# import jinja2
# import os

# Load the template
template_loader = jinja2.FileSystemLoader(searchpath="./template")
template_env = jinja2.Environment(loader=template_loader)
template = template_env.get_template("sui.rb.j2")
# # Load the template
# template_loader = jinja2.FileSystemLoader(searchpath="./template")
# template_env = jinja2.Environment(loader=template_loader)
# template = template_env.get_template("sui.rb.j2")

version = "${{ env.sui_tag }}".removeprefix("mainnet-v")
# version = "${{ env.sui_tag }}".removeprefix("mainnet-v")

# Render the template with variables
output = template.render(
version=version,
linux_sha256="${sha256_ubuntu_release}",
macos_intel_sha256="${sha256_macos_x86_release}",
macos_arm_sha256="${sha256_macos_arm_release}"
)
# # Render the template with variables
# output = template.render(
# version=version,
# linux_sha256="${sha256_ubuntu_release}",
# macos_intel_sha256="${sha256_macos_x86_release}",
# macos_arm_sha256="${sha256_macos_arm_release}"
# )

# Write the output to the formula file
with open("Formula/sui.rb", "w") as file:
file.write(output)
EOF
# # Write the output to the formula file
# with open("Formula/sui.rb", "w") as file:
# file.write(output)
# EOF

# Commit and Push to Target Repository
- name: Commit and Push to Target Repository
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.HOMEBREW_TAP_REPO_READ_WRITE }}
commit-message: "Update Homebrew formula for release ${{ env.sui_tag }}"
files: Formula/sui.rb
push-branch: main
rebase: 'true'
force-add: 'true'
name: ${{ github.triggering_actor }}
email: ${{ github.triggering_actor }}@users.noreply.github.com
# # Commit and Push to Target Repository
# - name: Commit and Push to Target Repository
# uses: github-actions-x/[email protected]
# with:
# github-token: ${{ secrets.HOMEBREW_TAP_REPO_READ_WRITE }}
# commit-message: "Update Homebrew formula for release ${{ env.sui_tag }}"
# files: Formula/sui.rb
# push-branch: main
# rebase: 'true'
# force-add: 'true'
# name: ${{ github.triggering_actor }}
# email: ${{ github.triggering_actor }}@users.noreply.github.com

# Tag all sui images with release tag, so that they can be easily found
tag-docker-hub-images:
runs-on: ubuntu-latest
steps:
- name: Dispatch Tagging of images in DockerHub, in MystenLabs/sui-operations
uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588 # pin@v2
with:
repository: MystenLabs/sui-operations
token: ${{ secrets.DOCKER_BINARY_BUILDS_DISPATCH }}
event-type: tag-docker-images
client-payload: '{"sui_commit": "${{ github.sha }}", "repo_name": "all", "tag": "${{ env.TAG_NAME }}"}'
# # Tag all sui images with release tag, so that they can be easily found
# tag-docker-hub-images:
# runs-on: ubuntu-latest
# steps:
# - name: Dispatch Tagging of images in DockerHub, in MystenLabs/sui-operations
# uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588 # pin@v2
# with:
# repository: MystenLabs/sui-operations
# token: ${{ secrets.DOCKER_BINARY_BUILDS_DISPATCH }}
# event-type: tag-docker-images
# client-payload: '{"sui_commit": "${{ github.sha }}", "repo_name": "all", "tag": "${{ env.TAG_NAME }}"}'
27 changes: 27 additions & 0 deletions chocolatey/sui.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter
enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>sui</id>
<version>$version$</version>
<owners>sui</owners>
<title>Main Sui Binary</title>
<authors>sui</authors>
<projectUrl>https://sui.io/</projectUrl>
<licenseUrl>https://github.com/MystenLabs/sui/blob/main/LICENSE</licenseUrl>
<iconUrl>https://assets-global.website-files.com/6425f546844727ce5fb9e5ab/643775f4a15c9a9e10426daa_Sui_Favicon_256.png</iconUrl>
<projectSourceUrl>https://github.com/MystenLabs/sui/</projectSourceUrl>
<bugTrackerUrl>https://github.com/MystenLabs/sui/issues</bugTrackerUrl>
<tags>sui</tags>
<packageSourceUrl>https://community.chocolatey.org/packages/sui.portable</packageSourceUrl>
<summary>Run a local sui binary</summary>
<description>Sui is the first internet-scale programmable blockchain platform</description>
<releaseNotes>https://github.com/MystenLabs/sui/releases/tag/mainnet-v$version$</releaseNotes>
</metadata>
<files>
<file src="./target/release/sui.exe" target="bin/sui.exe" />
<file src="./LICENSE" target="bin/LICENSE.txt" />
<file src="./chocolatey/VERIFICATION.txt" target="bin/VERIFICATION.txt" />
</files>
</package>

0 comments on commit 3893a4c

Please sign in to comment.