Skip to content

Commit

Permalink
Adding fixes for macOS to build.sh and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Nov 14, 2023
1 parent ab3e6fb commit 3b5acf7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/release.yml
Expand Up @@ -38,12 +38,10 @@ jobs:
- name: Build ${{ matrix.arch }}
run: |
./build.sh -v $VER -a ${{ matrix.arch }}
file build/linux/*/*/$APP
- name: Build ${{ matrix.arch }} (static)
if: matrix.arch != 'arm'
run: |
./build.sh -v $VER -a ${{ matrix.arch }} -s
file build/linux/*/*/${APP}_static
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -59,7 +57,8 @@ jobs:
arch: [amd64, arm64]
steps:
- name: Install build dependencies
run: brew install coreutils
run: |
brew install coreutils gnu-tar
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
Expand All @@ -69,7 +68,6 @@ jobs:
- name: Build ${{ matrix.arch }}
run: |
./build.sh -v $VER -a ${{ matrix.arch }}
file build/darwin/*/*/$APP
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -84,19 +82,20 @@ jobs:
runs-on: macos-latest
steps:
- name: Install build dependencies
run: brew install coreutils
run: |
brew install coreutils gnu-tar
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Build universal
run: |
export WORKDIR=$PWD/build/darwin/universal/$VER
mkdir -p $WORKDIR
tar -zxvf dist-darwin-amd64/*/*/*.tar.gz -C $WORKDIR $APP
tar -zxvf dist-darwin-amd64/*/*/*.tar.gz -C $WORKDIR LICENSE
gtar -jxvf dist-darwin-amd64/*/*/*.tar.bz2 -C $WORKDIR $APP
gtar -jxvf dist-darwin-amd64/*/*/*.tar.bz2 -C $WORKDIR LICENSE
mv $WORKDIR/$APP $WORKDIR/$APP-amd64
tar -zxvf dist-darwin-arm64/*/*/*.tar.gz -C $WORKDIR $APP
gtar -jxvf dist-darwin-arm64/*/*/*.tar.bz2 -C $WORKDIR $APP
mv $WORKDIR/$APP $WORKDIR/$APP-arm64
file $WORKDIR/$APP-{amd64,arm64}
Expand All @@ -107,7 +106,9 @@ jobs:
rm $WORKDIR/$APP-{amd64,arm64}
tar -C $WORKDIR -czf $WORKDIR/$APP-${VER#v}-darwin-universal.tar.gz $APP LICENSE
sudo /usr/sbin/purge
gtar -C $WORKDIR -cjf $WORKDIR/$APP-${VER#v}-darwin-universal.tar.bz2 $APP LICENSE
ls -alh $WORKDIR/*
sha256sum $WORKDIR/*
- name: Archive artifacts
Expand All @@ -131,7 +132,8 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: Build amd64
shell: bash
run: ./build.sh -v $VER
run: |
./build.sh -v $VER
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -158,5 +160,5 @@ jobs:
draft: true
generate_release_notes: true
files: |
dist-*/*/*/*.gz
dist-*/*/*/*.tar.bz2
dist-*/*/*/*.zip
42 changes: 30 additions & 12 deletions build.sh
Expand Up @@ -65,17 +65,22 @@ VER="${VER#v}"
BUILD=$SRC/build
DIR=$BUILD/$PLATFORM/$ARCH/$VER

EXT=tar.gz
TAR=tar
EXT=tar.bz2
BIN=$DIR/$NAME

case $PLATFORM in
darwin|linux)
linux)
TAGS+=(no_adodb)
;;
windows)
EXT=zip
BIN=$BIN.exe
;;
darwin)
TAGS+=(no_adodb)
TAR=gtar
;;
esac
OUT=$DIR/$NAME-$VER-$PLATFORM-$ARCH.$EXT

Expand Down Expand Up @@ -201,6 +206,22 @@ if [[ "$INSTALL" == "1" || "$BUILDONLY" == "1" ]]; then
exit
fi

(set -x;
file $BIN
)
if [[ "$PLATFORM" != "windows" ]]; then
(set -x;
chmod +x $BIN
)
fi

# purge disk cache
if [[ "$PLATFORM" == "darwin" && "$CI" == "true" ]]; then
(set -x;
sudo /usr/sbin/purge
)
fi

built_ver() {
if [[ "$PLATFORM" == "linux" && "$ARCH" != "$GOARCH" ]]; then
EXTRA=
Expand Down Expand Up @@ -231,23 +252,20 @@ fi
# pack
cp $SRC/LICENSE $DIR
case $EXT in
tar.gz)
tar -C $DIR -czf $OUT $(basename $BIN) LICENSE
;;
zip)
zip $OUT -j $BIN LICENSE
;;
tar.bz2) $TAR -C $DIR -cjf $OUT $(basename $BIN) LICENSE ;;
zip) zip $OUT -j $BIN LICENSE ;;
esac

# report
echo "PACKED: $OUT ($(du -sh $OUT|awk '{print $1}'))"

case $EXT in
tar.gz) tar -zvtf $OUT ;;
zip) unzip -l $OUT ;;
tar.bz2) (set -x; $TAR -jvtf $OUT) ;;
zip) (set -x; unzip -l $OUT) ;;
esac

echo "SHA256SUM:"
sha256sum $DIR/*
(set -x;
sha256sum $DIR/*
)

popd &> /dev/null

0 comments on commit 3b5acf7

Please sign in to comment.