Fix snap publishing flow, publish assets independently

This commit is contained in:
Ian Davis 2022-07-24 22:16:16 -07:00
parent 156fb17dad
commit 8a41a6bb5b
5 changed files with 172 additions and 53 deletions

View File

@ -115,7 +115,7 @@ jobs:
command: | command: |
git --no-pager diff go.mod go.sum git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum git --no-pager diff --quiet go.mod go.sum
build-all: build-linux:
executor: golang executor: golang
steps: steps:
- install-deps - install-deps
@ -518,6 +518,19 @@ jobs:
publish: publish:
description: publish binary artifacts description: publish binary artifacts
executor: ubuntu executor: ubuntu
parameters:
linux:
default: false
description: publish linux binaries?
type: boolean
darwin:
default: false
description: publish darwin binaries?
type: boolean
appimage:
default: false
description: publish appimage binaries?
type: boolean
steps: steps:
- run: - run:
name: Install git jq curl name: Install git jq curl
@ -528,12 +541,21 @@ jobs:
- install_ipfs - install_ipfs
- attach_workspace: - attach_workspace:
at: "." at: "."
- run: - when:
name: Create bundles condition: << parameters.linux >>
command: ./scripts/build-bundle.sh steps:
- run: - run: ./scripts/build-arch-bundle.sh linux
name: Publish release - run: ./scripts/publish-arch-release.sh linux
command: ./scripts/publish-release.sh - when:
condition: << parameters.darwin>>
steps:
- run: ./scripts/build-arch-bundle.sh darwin
- run: ./scripts/publish-arch-release.sh darwin
- when:
condition: << parameters.appimage >>
steps:
- run: ./scripts/build-appimage-bundle.sh
- run: ./scripts/publish-arch-release.sh appimage
publish-snapcraft: publish-snapcraft:
description: build and push snapcraft description: build and push snapcraft
@ -550,11 +572,6 @@ jobs:
- run: - run:
name: install snapcraft name: install snapcraft
command: sudo snap install snapcraft --classic command: sudo snap install snapcraft --classic
- run:
name: create snapcraft config file
command: |
mkdir -p ~/.config/snapcraft
echo "$SNAPCRAFT_LOGIN_FILE" | base64 -d > ~/.config/snapcraft/snapcraft.cfg
- run: - run:
name: build snap name: build snap
command: snapcraft --use-lxd command: snapcraft --use-lxd
@ -1020,7 +1037,7 @@ workflows:
only: only:
- master - master
- build-debug - build-debug
- build-all: - build-linux:
filters: filters:
tags: tags:
only: only:
@ -1042,6 +1059,18 @@ workflows:
only: only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/ - /^v\d+\.\d+\.\d+(-rc\d+)?$/
- build-appimage: - build-appimage:
filters:
branches:
only:
- /^release\/v\d+\.\d+\.\d+(-rc\d+)?$/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish:
name: publish-macos
darwin: true
requires:
- build-macos
filters: filters:
branches: branches:
ignore: ignore:
@ -1050,9 +1079,21 @@ workflows:
only: only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/ - /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish: - publish:
name: publish-linux
linux: true
requires:
- build-linux
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish:
name: publish-appimage
appimage: true
requires: requires:
- build-all
- build-macos
- build-appimage - build-appimage
filters: filters:
branches: branches:

View File

@ -115,7 +115,7 @@ jobs:
command: | command: |
git --no-pager diff go.mod go.sum git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum git --no-pager diff --quiet go.mod go.sum
build-all: build-linux:
executor: golang executor: golang
steps: steps:
- install-deps - install-deps
@ -518,6 +518,19 @@ jobs:
publish: publish:
description: publish binary artifacts description: publish binary artifacts
executor: ubuntu executor: ubuntu
parameters:
linux:
default: false
description: publish linux binaries?
type: boolean
darwin:
default: false
description: publish darwin binaries?
type: boolean
appimage:
default: false
description: publish appimage binaries?
type: boolean
steps: steps:
- run: - run:
name: Install git jq curl name: Install git jq curl
@ -528,12 +541,21 @@ jobs:
- install_ipfs - install_ipfs
- attach_workspace: - attach_workspace:
at: "." at: "."
- run: - when:
name: Create bundles condition: << parameters.linux >>
command: ./scripts/build-bundle.sh steps:
- run: - run: ./scripts/build-arch-bundle.sh linux
name: Publish release - run: ./scripts/publish-arch-release.sh linux
command: ./scripts/publish-release.sh - when:
condition: << parameters.darwin>>
steps:
- run: ./scripts/build-arch-bundle.sh darwin
- run: ./scripts/publish-arch-release.sh darwin
- when:
condition: << parameters.appimage >>
steps:
- run: ./scripts/build-appimage-bundle.sh
- run: ./scripts/publish-arch-release.sh appimage
publish-snapcraft: publish-snapcraft:
description: build and push snapcraft description: build and push snapcraft
@ -550,11 +572,6 @@ jobs:
- run: - run:
name: install snapcraft name: install snapcraft
command: sudo snap install snapcraft --classic command: sudo snap install snapcraft --classic
- run:
name: create snapcraft config file
command: |
mkdir -p ~/.config/snapcraft
echo "$SNAPCRAFT_LOGIN_FILE" | base64 -d > ~/.config/snapcraft/snapcraft.cfg
- run: - run:
name: build snap name: build snap
command: snapcraft --use-lxd command: snapcraft --use-lxd
@ -780,7 +797,7 @@ workflows:
only: only:
- master - master
- build-debug - build-debug
- build-all: - build-linux:
filters: filters:
tags: tags:
only: only:
@ -802,6 +819,18 @@ workflows:
only: only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/ - /^v\d+\.\d+\.\d+(-rc\d+)?$/
- build-appimage: - build-appimage:
filters:
branches:
only:
- /^release\/v\d+\.\d+\.\d+(-rc\d+)?$/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish:
name: publish-macos
darwin: true
requires:
- build-macos
filters: filters:
branches: branches:
ignore: ignore:
@ -810,9 +839,21 @@ workflows:
only: only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/ - /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish: - publish:
name: publish-linux
linux: true
requires:
- build-linux
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish:
name: publish-appimage
appimage: true
requires: requires:
- build-all
- build-macos
- build-appimage - build-appimage
filters: filters:
branches: branches:

View File

@ -1,11 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
ARCHS=(
"darwin"
"linux"
)
REQUIRED=( REQUIRED=(
"ipfs" "ipfs"
"sha512sum" "sha512sum"
@ -31,24 +26,6 @@ PID="$!"
trap "kill -9 ${PID}" EXIT trap "kill -9 ${PID}" EXIT
sleep 30 sleep 30
for ARCH in "${ARCHS[@]}"
do
mkdir -p "${ARCH}/lotus"
pushd "${ARCH}"
for BINARY in "${BINARIES[@]}"
do
cp "../../${ARCH}/${BINARY}" "lotus/"
chmod +x "lotus/${BINARY}"
done
tar -zcvf "../lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" lotus
popd
rm -rf "${ARCH}"
sha512sum "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" > "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz.sha512"
ipfs add -q "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" > "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz.cid"
done
cp "../appimage/Lotus-${CIRCLE_TAG}-x86_64.AppImage" . cp "../appimage/Lotus-${CIRCLE_TAG}-x86_64.AppImage" .
sha512sum "Lotus-${CIRCLE_TAG}-x86_64.AppImage" > "Lotus-${CIRCLE_TAG}-x86_64.AppImage.sha512" sha512sum "Lotus-${CIRCLE_TAG}-x86_64.AppImage" > "Lotus-${CIRCLE_TAG}-x86_64.AppImage.sha512"
ipfs add -q "Lotus-${CIRCLE_TAG}-x86_64.AppImage" > "Lotus-${CIRCLE_TAG}-x86_64.AppImage.cid" ipfs add -q "Lotus-${CIRCLE_TAG}-x86_64.AppImage" > "Lotus-${CIRCLE_TAG}-x86_64.AppImage.cid"

46
scripts/build-arch-bundle Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -ex
ARCH=$1
REQUIRED=(
"ipfs"
"sha512sum"
)
for REQUIRE in "${REQUIRED[@]}"
do
command -v "${REQUIRE}" >/dev/null 2>&1 || echo >&2 "'${REQUIRE}' must be installed"
done
mkdir bundle
pushd bundle
BINARIES=(
"lotus"
"lotus-miner"
"lotus-worker"
)
export IPFS_PATH=`mktemp -d`
ipfs init
ipfs daemon &
PID="$!"
trap "kill -9 ${PID}" EXIT
sleep 30
mkdir -p "${ARCH}/lotus"
pushd "${ARCH}"
for BINARY in "${BINARIES[@]}"
do
cp "../../${ARCH}/${BINARY}" "lotus/"
chmod +x "lotus/${BINARY}"
done
tar -zcvf "../lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" lotus
popd
rm -rf "${ARCH}"
sha512sum "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" > "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz.sha512"
ipfs add -q "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz" > "lotus_${CIRCLE_TAG}_${ARCH}-amd64.tar.gz.cid"
popd

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
ARCH=$1
pushd bundle pushd bundle
# make sure we have a token set, api requests won't work otherwise # make sure we have a token set, api requests won't work otherwise
@ -61,23 +63,35 @@ fi
RELEASE_UPLOAD_URL=`echo "${RELEASE_RESPONSE}" | jq -r '.upload_url' | cut -d'{' -f1` RELEASE_UPLOAD_URL=`echo "${RELEASE_RESPONSE}" | jq -r '.upload_url' | cut -d'{' -f1`
echo "Preparing to send artifacts to ${RELEASE_UPLOAD_URL}" echo "Preparing to send artifacts to ${RELEASE_UPLOAD_URL}"
if [ $ARCH = 'linux' ]; then
artifacts=( artifacts=(
"lotus_${CIRCLE_TAG}_linux-amd64.tar.gz" "lotus_${CIRCLE_TAG}_linux-amd64.tar.gz"
"lotus_${CIRCLE_TAG}_linux-amd64.tar.gz.cid" "lotus_${CIRCLE_TAG}_linux-amd64.tar.gz.cid"
"lotus_${CIRCLE_TAG}_linux-amd64.tar.gz.sha512" "lotus_${CIRCLE_TAG}_linux-amd64.tar.gz.sha512"
)
elif [ $ARCH = 'darwin' ]; then
artifacts=(
"lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz" "lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz"
"lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz.cid" "lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz.cid"
"lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz.sha512" "lotus_${CIRCLE_TAG}_darwin-amd64.tar.gz.sha512"
)
elif [ $ARCH = 'appimage' ]; then
artifacts=(
"Lotus-${CIRCLE_TAG}-x86_64.AppImage" "Lotus-${CIRCLE_TAG}-x86_64.AppImage"
"Lotus-${CIRCLE_TAG}-x86_64.AppImage.cid" "Lotus-${CIRCLE_TAG}-x86_64.AppImage.cid"
"Lotus-${CIRCLE_TAG}-x86_64.AppImage.sha512" "Lotus-${CIRCLE_TAG}-x86_64.AppImage.sha512"
) )
else
echo "$1 is not a supported architecture to publish a release for" 1>&2
exit 1
fi
for RELEASE_FILE in "${artifacts[@]}" for RELEASE_FILE in "${artifacts[@]}"
do do
echo "Uploading ${RELEASE_FILE}..." echo "Uploading ${RELEASE_FILE}..."
curl \ curl \
--request POST \ --request POST \
--fail \
--header "Authorization: token ${GITHUB_TOKEN}" \ --header "Authorization: token ${GITHUB_TOKEN}" \
--header "Content-Type: application/octet-stream" \ --header "Content-Type: application/octet-stream" \
--data-binary "@${RELEASE_FILE}" \ --data-binary "@${RELEASE_FILE}" \