Skip to content

Commit

Permalink
remove darwin job & fix distribute zbox workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
storybehind committed Aug 5, 2024
1 parent ca5f3ef commit 3ff3f1e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 107 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/distribute-zboxcli.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: Build, Distribute and Test zbox

on:
push: # REMOVE: push once tested
branches:
- packaging
workflow_dispatch:
inputs:
version:
description: 'Version of zbox to release'
required: true
default: 'v1.0.0'

env:
APP_NAME: zbox
APP_VERSION: 1.16.0-1
APP_VERSION: v1.16.0 # REMOVE: take as input from workflow
GO_VERSION: 1.21.0
REMOTE_SERVER: 5.9.151.246
REMOTE_USER: root
Expand Down Expand Up @@ -132,7 +140,7 @@ jobs:
DISTRIBUTIONS: bionic focal jammy noble bookworm bullseye buster
ARCHITECTURES: amd64 arm64
SRC_DIR: ${{ github.workspace }}/src
REPO_DIR: ${{ github.workspace }}/aptrepo
REPO_DIR: ${{ github.workspace }}/zbox
DEB_DIR: ${{ github.workspace }}/deb-files
steps:
- name: Checkout code
Expand Down Expand Up @@ -169,7 +177,7 @@ jobs:
- name: Download APT repo
run: |
scp -v -i ~/.ssh/id_rsa -r ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/ ${{ github.workspace }}
scp -v -i ~/.ssh/id_rsa -r ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/zbox/ ${{ github.workspace }}
- name: Download all .deb files
uses: actions/download-artifact@v3
Expand All @@ -188,26 +196,26 @@ jobs:
run: |
cd ${{ env.REPO_DIR }}
for dist in ${{ env.DISTRIBUTIONS }}; do
for arch in ${{ env.ARCHITECTURES }}; do
mkdir -p dists/${dist}/main/binary-${arch}
apt-ftparchive packages pool/main > dists/${dist}/main/binary-${arch}/Packages
done
apt-ftparchive release -o APT::FTPArchive::Release::Origin="${{ env.APP_NAME }}" \
apt-ftparchive -o APT::FTPArchive::Release::Origin="${{ env.APP_NAME }}" \
-o APT::FTPArchive::Release::Label="${{ env.APP_NAME }}" \
-o APT::FTPArchive::Release::Suite="${dist}" \
-o APT::FTPArchive::Release::Codename="${dist}" \
-o APT::FTPArchive::Release::Version="${{ env.APP_VERSION }}" \
-o APT::FTPArchive::Release::Architectures="${{ env.ARCHITECTURES }}" \
-o APT::FTPArchive::Release::Components="main" \
dists/${dist} > dists/${dist}/Release
-o Tree::dists/${dist}::Sections="main" \
-o Tree::dists/${dist}::Architectures="${{ env.ARCHITECTURES }}" \
-o Dir::ArchiveDir="${{ env.REPO_DIR }}" \
packages pool/main override-file \
release dists/${dist}
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --default-key ${{ secrets.GPG_KEY_ID }} --batch --yes --passphrase-fd 0 -abs -o dists/${dist}/Release.gpg dists/${dist}/Release
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --default-key ${{ secrets.GPG_KEY_ID }} --batch --yes --passphrase-fd 0 --clearsign -o dists/${dist}/InRelease dists/${dist}/Release
done
- name: Upload APT repo to remote
run: |
scp -v -i ~/.ssh/id_rsa -r ${{ github.workspace }}/aptrepo/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/
scp -v -i ~/.ssh/id_rsa -r ${{ github.workspace }}/zbox/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/
- name: Upload GPG public key to remote server
run: |
Expand All @@ -216,7 +224,7 @@ jobs:
- name: Upload install script to remote server
run: |
scp -v -i ~/.ssh/id_rsa ${{ env.SRC_DIR }}/scripts/debian/install.sh ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/deb_install.sh
scp -v -i ~/.ssh/id_rsa ${{ env.SRC_DIR }}/scripts/debian/install.sh ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/zbox_deb_install.sh

Expand Down Expand Up @@ -266,7 +274,7 @@ jobs:
docker buildx build \
--platform ${{ matrix.arch.platform }} \
--build-arg BASE_IMAGE=${{ matrix.distro.base_image }} \
--build-arg LOC="https://packages.zus.network/deb_install.sh" \
--build-arg LOC="https://packages.zus.network/aptrepo/zbox_deb_install.sh" \
--tag ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }} \
--load \
--output type=docker,dest=${{ github.workspace }}/${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}.tar \
Expand Down
92 changes: 3 additions & 89 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,103 +6,17 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version of zboxcli to release'
description: 'Version of zbox to release'
required: true
default: '1.0.0'
dry_run:
description: 'Run without making changes'
required: false
default: 'false'
default: 'v1.0.0'

env:
GITHUB_TOKEN: ${{ secrets.GOSDK }}
VERSION: 1.16.0 # take as input from workflow
VERSION: v1.16.0 # take as input from workflow
APP_NAME: zbox
GO_VERSION: 1.21

jobs:
darwin:
runs-on: ubuntu-latest
env:
SRC_DIR: ${{ github.workspace }}/src
OUTPUT_DIR: ${{ github.workspace }}/output
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: ${{ env.SRC_DIR }}

- name: Setup
run : |
mkdir -p ${{ env.OUTPUT_DIR }}
sudo apt-get update
sudo apt-get install -y clang cmake git patch python-is-python3 libssl-dev lzma-dev libxml2-dev xz-utils bzip2 cpio libbz2-dev zlib1g-dev
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up osxcross
run: |
cd ${{ github.workspace }}
git clone https://github.com/tpoechtrager/osxcross.git
cd osxcross/tarballs
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
cd ..
export CC=clang
export CXX=clang++
UNATTENDED=yes OSX_VERSION_MIN=10.10 ./build.sh
- name: Cross-compile for Darwin/amd64
run: |
cd ${{ env.SRC_DIR }}
export OSXCROSS_ROOT=${{ github.workspace }}/osxcross
export PATH=$OSXCROSS_ROOT/target/bin:$PATH
export GO111MODULE=on
export CGO_ENABLED=1
find /usr -name "libstdc++*" # debug
o64-clang -v
o64-clang++ -v
echo "Building for Darwin/amd64..."
CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 go build -x -v -tags bn256 -ldflags "-X main.VersionStr=${{env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} .
echo "Build completed."
- name: Create Zip File for Darwin/amd64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-darwin-amd64.zip ${{ env.APP_NAME }}
- name: Upload Zip for Darwin/amd64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-darwin-amd64
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-darwin-amd64.zip

- name: Cross-compile for Darwin/arm64
run: |
cd ${{ env.SRC_DIR }}
export OSXCROSS_ROOT=${{ github.workspace }}/osxcross
export PATH=$OSXCROSS_ROOT/target/bin:$PATH
export GO111MODULE=on
export CGO_ENABLED=1
echo "Building for Darwin/arm64..."
CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=arm64 go build -x -v -tags bn256 -ldflags "-X main.VersionStr=${{env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} .
echo "Build completed."
- name: Create Zip File for Darwin/arm64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-darwin-arm64.zip ${{ env.APP_NAME }}
- name: Upload Zip for Darwin/arm64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-darwin-arm64
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-darwin-arm64.zip

linux:
runs-on: ubuntu-latest
env:
Expand Down
2 changes: 1 addition & 1 deletion scripts/debian/Dockerfile.install_test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y curl dpkg
RUN dpkg --print-architecture

# Download and install the app
ARG LOC=https://packages.zus.network/deb_install.sh
ARG LOC=https://packages.zus.network/aptrepo/zbox_deb_install.sh
RUN set -e; \
curl -sL ${LOC} | bash

Expand Down
10 changes: 5 additions & 5 deletions scripts/debian/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ setup() {
if [[ -z $DIST_CODE ]]; then
CLI_REPO=$(lsb_release -cs)
shopt -s nocasematch
ERROR_MSG="Unable to find a package for your system. Please check if an existing package in https://packages.zus.network/aptrepo/dists/ can be used in your system and install with the dist name: 'curl -sL https://packages.zus.network/deb_install.sh | sudo DIST_CODE=<dist_code_name> bash'"
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/dists/) =~ $CLI_REPO ]]; then
ERROR_MSG="Unable to find a package for your system. Please check if an existing package in https://packages.zus.network/aptrepo/zbox/dists/ can be used in your system and install with the dist name: 'curl -sL https://packages.zus.network/aptrepo/zbox_deb_install.sh | sudo DIST_CODE=<dist_code_name> bash'"
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zbox/dists/) =~ $CLI_REPO ]]; then
DIST=$(lsb_release -is)
if [[ $DIST =~ "Ubuntu" ]]; then
CLI_REPO="jammy"
Expand All @@ -42,8 +42,8 @@ setup() {
fi
else
CLI_REPO=$DIST_CODE
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/dists/) =~ $CLI_REPO ]]; then
echo "Unable to find an zbox-cli package with DIST_CODE=$CLI_REPO in https://packages.zus.network/aptrepo/dists/"
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zbox/dists/) =~ $CLI_REPO ]]; then
echo "Unable to find an zbox package with DIST_CODE=$CLI_REPO in https://packages.zus.network/aptrepo/zbox/dists/"
exit 1
fi
fi
Expand All @@ -53,7 +53,7 @@ setup() {
fi

echo "Types: deb
URIs: https://packages.zus.network/aptrepo/
URIs: https://packages.zus.network/aptrepo/zbox/
Suites: ${CLI_REPO}
Components: main
Architectures: $(dpkg --print-architecture)
Expand Down

0 comments on commit 3ff3f1e

Please sign in to comment.