Skip to content

Commit

Permalink
fix update apt repo step
Browse files Browse the repository at this point in the history
  • Loading branch information
storybehind committed Aug 6, 2024
1 parent c533bcc commit ae95266
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 28 deletions.
53 changes: 32 additions & 21 deletions .github/workflows/distribute-zwalletcli.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: Build, Distribute and Test zwallet

on:
push:
push: # REMOVE: push once tested
branches:
- main
- packaging
workflow_dispatch:
inputs:
version:
description: 'Version of zwallet to release'
required: true
default: '1.0.0'

env:
APP_NAME: zwallet
APP_VERSION: 1.16.0-1
APP_VERSION: 1.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 @@ -101,7 +106,6 @@ jobs:
Package: ${{ env.APP_NAME }}
Version: ${{ env.APP_VERSION }}
Architecture: ${{ matrix.arch.name }}
Maintainer: none <no-reply@gmail.com>
Description: zwallet is a command line interface (CLI) to demonstrate the wallet functionalities of Züs.
EOT
Expand Down Expand Up @@ -135,7 +139,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 }}/zwallet
DEB_DIR: ${{ github.workspace }}/deb-files
steps:
- name: Checkout code
Expand Down Expand Up @@ -172,7 +176,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/zwallet/ ${{ github.workspace }}
- name: Download all .deb files
uses: actions/download-artifact@v3
Expand All @@ -181,36 +185,43 @@ jobs:

- name: Copy debian packages
run : |
mkdir -p ${{ env.REPO_DIR }}/pool/main/z/${APP_NAME}/
mkdir -p ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/
find ${{ env.DEB_DIR }} -name "*.deb"
for deb in $(find ${{ env.DEB_DIR }} -name "*.deb"); do
cp $deb ${{ env.REPO_DIR }}/pool/main/z/${APP_NAME}/
cp $deb ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/
done
- name: Update APT repo
run: |
cd ${{ env.REPO_DIR }}
for dist in ${{ env.DISTRIBUTIONS }}; do
mkdir -p dists/${dist}
for arch in ${{ env.ARCHITECTURES }}; do
mkdir -p dists/${dist}/main/binary-${arch}
apt-ftparchive packages pool/main > dists/${dist}/main/binary-${arch}/Packages
mkdir -p dists/${dist}/main/binary-${arch}
find "pool/main/z/${{ env.APP_NAME }}" -type f -name "${{ env.APP_NAME }}_*~${dist}_${arch}.deb" | \
xargs -I {} apt-ftparchive -o Tree::dists/${dist}::Sections="main" \
-o Tree::dists/${dist}::Architectures="${arch}" \
-o Dir::ArchiveDir="${{ env.REPO_DIR }}" \
packages {} > dists/${dist}/main/binary-${arch}/Packages
done
apt-ftparchive release -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
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" \
-o Dir::ArchiveDir="${{ env.REPO_DIR }}" \
release dists/${dist} > dists/${dist}/Release
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 }}/zwallet/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/
- name: Upload GPG public key to remote server
run: |
Expand All @@ -219,7 +230,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/zwallet_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/zwallet_deb_install.sh

Expand Down Expand Up @@ -269,7 +280,7 @@ jobs:
docker buildx build \
--platform ${{ matrix.arch.platform }} \
--build-arg BASE_IMAGE=${{ matrix.distro.base_image }} \
--build-arg LOC="https://packages.zus.network/zwallet_deb_install.sh" \
--build-arg LOC="https://packages.zus.network/aptrepo/zwallet_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
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release
on:
push: # REMOVE: push once tested
branches:
- packaging
workflow_dispatch:
inputs:
version:
description: 'Version of zwallet to release'
required: true
default: '1.0.0'

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

jobs:
linux:
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: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Install zip
uses: montudor/action-zip@v1

- name: Setup
run : |
mkdir -p ${{ env.OUTPUT_DIR }}
- name: Build Docker image for linux/amd64
run: |
docker buildx create --use
docker buildx build \
--platform linux/amd64 \
--build-arg VERSION=${{ env.VERSION }} \
--tag ${{ env.APP_NAME }}-amd64 \
--load \
--output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar \
-f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }}
- name: Load image ${{ env.APP_NAME }}-amd64 & Extract binary ${{ env.APP_NAME }} from container
run: |
docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar
CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-amd64)
docker cp ${CONTAINER_ID}:/zwallet ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}
docker rm ${CONTAINER_ID}
- name: Create Zip File for linux/amd64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }}
- name: Upload Zip for Darwin/amd64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-amd64
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip

- name: Build Docker image for linux/arm64
run: |
docker buildx create --use
docker buildx build \
--platform linux/arm64 \
--build-arg VERSION=${{ env.VERSION }} \
--tag ${{ env.APP_NAME }}-arm64 \
--load \
--output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar \
-f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }}
- name: Load image ${{ env.APP_NAME }}-arm64 & Extract binary from container
run: |
docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar
CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-arm64)
docker cp ${CONTAINER_ID}:/zwallet ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}
docker rm ${CONTAINER_ID}
- name: Create Zip File for linux/arm64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }}
- name: Upload Zip for Darwin/arm64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-arm64
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip

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/zwallet_deb_install.sh
ARG LOC=https://packages.zus.network/aptrepo/zwallet_deb_install.sh
RUN set -e; \
curl -sL ${LOC} | bash

Expand Down
12 changes: 6 additions & 6 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/zwallet_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/zwallet/dists/ can be used in your system and install with the dist name: 'curl -sL https://packages.zus.network/aptrepo/zwallet_deb_install.sh | sudo DIST_CODE=<dist_code_name> bash'"
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zwallet/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 zwallet-cli package with DIST_CODE=$CLI_REPO in https://packages.zus.network/aptrepo/dists/"
if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zwallet/dists/) =~ $CLI_REPO ]]; then
echo "Unable to find an zwallet package with DIST_CODE=$CLI_REPO in https://packages.zus.network/aptrepo/zwallet/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/zwallet/
Suites: ${CLI_REPO}
Components: main
Architectures: $(dpkg --print-architecture)
Expand All @@ -71,7 +71,7 @@ Signed-by: /etc/apt/keyrings/zus.gpg" | tee /etc/apt/sources.list.d/zwallet.sour
touch $CONFIG_PATH
cat <<EOT > ${CONFIG_PATH}
---
block_worker: https://dev.zus.network
block_worker: https://dev.zus.network # UPDATE: mainnet url
signature_scheme: bls0chain
min_submit: 50
min_confirmation: 50
Expand Down

0 comments on commit ae95266

Please sign in to comment.