Skip to content

Commit

Permalink
updating macOS releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f committed Jan 27, 2024
1 parent 22f935e commit 022b5c5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/releasers/macos/gui.bundle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" standalone="no"?>
<app-bundle>
<meta>
<prefix name="default">/usr/local</prefix>
<prefix name="default">${env:PREFIX}</prefix>
<prefix name="bundle">${env:GUI_BUNDLE}</prefix>
<destination overwrite="yes">${env:ROOT_DIR}</destination>
<gtk>gtk+-3.0</gtk>
Expand Down
16 changes: 14 additions & 2 deletions .github/releasers/releaser_gui_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ BUILD_DIR="${ROOT_DIR}/build"
PACKAGE_NAME="pactus-gui_${VERSION}"
PACKAGE_DIR="${ROOT_DIR}/${PACKAGE_NAME}"

# Check if the architecture is amd64 and update FILE_NAME accordingly
ARCHITECTURE="$(uname -m)" # Get the machine architecture

if [ "${ARCHITECTURE}" = "x86_64" ]; then
FILE_NAME="${PACKAGE_NAME}_darwin_amd64"
elif [ "${ARCHITECTURE}" = "arm64" ]; then
FILE_NAME="${PACKAGE_NAME}_darwin_arm64"
else
echo "Unsupported architecture: ${ARCHITECTURE}"
exit 1
fi

mkdir ${PACKAGE_DIR}

echo "Building the binaries"
Expand Down Expand Up @@ -56,12 +68,12 @@ echo "Creating dmg"
# https://github.com/create-dmg/create-dmg
create-dmg \
--volname "Pactus GUI" \
"${PACKAGE_NAME}_darwin_amd64.dmg" \
"${FILE_NAME}.dmg" \
"${ROOT_DIR}/pactus-gui.app"

echo "Creating archive"
cp ${BUILD_DIR}/pactus-daemon ${PACKAGE_DIR}
cp ${BUILD_DIR}/pactus-wallet ${PACKAGE_DIR}
cp -R ${ROOT_DIR}/pactus-gui.app ${PACKAGE_DIR}

tar -czvf ${ROOT_DIR}/${PACKAGE_NAME}_darwin_amd64.tar.gz -p ${PACKAGE_NAME}
tar -czvf ${ROOT_DIR}/${FILE_NAME}.tar.gz -p ${PACKAGE_NAME}
57 changes: 56 additions & 1 deletion .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
########################################
build-gui-macos:
runs-on: macos-latest
env:
PREFIX: /usr/local

outputs:
checksums: ${{ steps.calc_checksums.outputs.checksums }}
Expand All @@ -101,7 +103,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install Dependencies
run: brew install gtk+3 librsvg create-dmg coreutils
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf

- name: Install Go
uses: actions/setup-go@v3
Expand Down Expand Up @@ -129,6 +131,59 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

########################################
## Follow these steps to release macOS ARM:
##
## 1- Login to server using VNC (Read the related issue: https://stackoverflow.com/a/9706088)
## 2- Login to the server using SSH
## 3- Install Homebrew: https://brew.sh/
## 4- Add self-runner: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners
## 5- Run the action
##
build-gui-macos-arm:
runs-on: self-hosted
env:
# In M1 Macs `/usr/local` moved to `/opt/homebrew`.
# More info: https://earthly.dev/blog/homebrew-on-m1/
#
PREFIX: /opt/homebrew

outputs:
checksums: ${{ steps.calc_checksums.outputs.checksums }}

steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: Create release files
run: bash ./.github/releasers/releaser_gui_macos.sh

- name: Calculate sha256sum
id: calc_checksums
run: |
set -e
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "checksums<<$EOF" >> "$GITHUB_OUTPUT"
echo "$(sha256sum pactus-*.dmg pactus-*tar.gz)" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Publish
uses: softprops/action-gh-release@v1
with:
files: |
pactus-*.dmg
pactus-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


########################################
build-gui-windows:
runs-on: windows-latest
Expand Down

0 comments on commit 022b5c5

Please sign in to comment.