Skip to content

Commit

Permalink
ci: create zip archive for release build
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Jan 28, 2023
1 parent 1037a5b commit 86e7979
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
echo git_ref_name="$(git describe --always)" >> $GITHUB_ENV
- name: Build Squirrel
run: ./action-build.sh
run: ./action-build.sh package

- name: Upload Squirrel artifact
uses: actions/upload-artifact@v3
with:
name: Squirrel-${{ env.git_ref_name }}.zip
path: ./**/*.pkg
path: package/*.pkg
# keep 90 days
retention-days: 90
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
echo git_ref_name="$(git describe --always)" >> $GITHUB_ENV
- name: Build Squirrel
run: ./action-build.sh
run: ./action-build.sh package

- name: Upload Squirrel artifact
uses: actions/upload-artifact@v3
with:
name: Squirrel-${{ env.git_ref_name }}.zip
path: ./**/*.pkg
path: package/*.pkg
# keep 30 days
retention-days: 30
4 changes: 2 additions & 2 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: true

- name: Build Squirrel
run: ./action-build.sh
run: ./action-build.sh archive

- name: Build changelog
id: release_log
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "./**/*.pkg"
artifacts: "package/*.zip"
body: |
${{ steps.release_log.outputs.changelog }}
draft: true
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ bin/*
lib/*
data/opencc/
data/plum/
download/
package/Squirrel.pkg
package/archives/*
package/sign/*.pem
package/test-*
*~
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ archive: package

sign-archive:
[ -n "${checksum}" ] || (echo >&2 'ERROR: $$checksum not specified.'; false)
bash package/make_archive
sign_key=sign/dsa_priv.pem bash package/make_archive

DSTROOT = /Library/Input Methods
SQUIRREL_APP_ROOT = $(DSTROOT)/Squirrel.app
Expand Down
6 changes: 4 additions & 2 deletions action-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

target="${1:-release}"

# export BUILD_UNIVERSAL=1

# preinstall
Expand All @@ -11,7 +13,7 @@ set -e
# make deps

# build Squirrel
make package
make "${target}"

echo 'Installer package:'
find . -type f -name "*.pkg"
find package -type f -name '*.pkg' -or -name '*.zip'
4 changes: 2 additions & 2 deletions action-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ rime_deps_download_url="https://github.com/rime/librime/releases/download/${rime

mkdir -p download && (
cd download
curl -LO "${rime_download_url}"
[ -z "${no_download}" ] && curl -LO "${rime_download_url}"
tar --bzip2 -xf "${rime_archive}"
curl -LO "${rime_deps_download_url}"
[ -z "${no_download}" ] && curl -LO "${rime_deps_download_url}"
tar --bzip2 -xf "${rime_deps_archive}"
)

Expand Down
Empty file removed package/archives/.placeholder
Empty file.
27 changes: 21 additions & 6 deletions package/make_archive
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
#! /bin/bash
# enconding: utf-8

set -e

cd "$(dirname $0)"
source common.sh

app_version="$(get_app_version)"
download_url="https://dl.bintray.com/rime/squirrel/Squirrel-${app_version}.zip"
target_archive="archives/Squirrel-${app_version}.zip"
target_archive="Squirrel-${app_version}.zip"
download_url="https://github.com/rime/squirrel/releases/${app_version}/${target_archive}"

if [ -n "${checksum}" ]; then
verify_archive() {
if ! [ -f "${target_archive}" ]; then
echo >&2 "ERROR: file does not exit: ${target_archive}"
exit 1
fi
echo 'sha256 checksum:'
echo "${checksum} ${target_archive}"
shasum -a 256 -c <<<"${checksum} ${target_archive}" || exit 1
else
}

create_archive() {
if [ -e "${target_archive}" ]; then
echo >&2 "ERROR: target archive already exists: ${target_archive}"
exit 1
fi
zip -r "${target_archive}" Squirrel.pkg
echo 'sha256 checksum:'
shasum -a 256 "${target_archive}"
}

if [ -n "${checksum}" ]; then
verify_archive
else
create_archive
fi

ls -l ${target_archive}
# sign_key: the private key file for signing the zip archive in Sparkle appcast.
# usage: checksum='...' sign_key='sign/dsa_priv.pem' ./make_archive
if [ -z "${sign_key}" ]; then
echo 'sign_key unspecified; skip signing.'
exit
fi

dsa_signature=$(ruby sign/sign_update.rb "${target_archive}" sign/dsa_priv.pem)
dsa_signature=$(ruby sign/sign_update.rb "${target_archive}" "${sign_key}")
file_length=$(stat -f%z "${target_archive}")
pub_date=$(date -R)

Expand Down

0 comments on commit 86e7979

Please sign in to comment.