forked from 1Password/typeshare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release] Updating typeshare release flow
- Loading branch information
1 parent
ee4d3d3
commit a6c8560
Showing
4 changed files
with
142 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,7 @@ dist/ | |
# IDE specific files | ||
.idea/ | ||
.vscode/ | ||
|
||
upload.txt | ||
dist-manifest.json | ||
.intentionally-empty-file.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Deploy binary to releases | ||
|
||
This script is used to deploy a binary to the releases page of a GitHub repository. | ||
|
||
## Pre-requisites | ||
`gh cli` must be installed and authenticated. | ||
|
||
Installation: | ||
```sh | ||
brew install gh | ||
``` | ||
|
||
Authentication: | ||
```sh | ||
gh auth login | ||
``` | ||
|
||
## Usage | ||
|
||
```sh | ||
Usage: ./build.sh [options] | ||
Options: | ||
--version <version> Version of the release | ||
--target <platform> Target platform | ||
Platforms: | ||
* "aarch64-apple-darwin" | ||
* "x86_64-apple-darwin" | ||
* "aarch64-unknown-linux-gnu" | ||
* "x86_64-unknown-linux-gnu" | ||
* "x86_64-pc-windows-msvc" | ||
``` | ||
|
||
## Example | ||
|
||
```sh | ||
./build.sh --version 1.12.0 --target aarch64-apple-darwin | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
|
||
set -e | ||
|
||
function help() { | ||
echo "Usage: $0 [options]" | ||
echo "Options:" | ||
echo " --version <version> Version of the release" | ||
echo " --target <platform> Target platform" | ||
echo " Platforms: " | ||
echo " * \"aarch64-apple-darwin\"" | ||
echo " * \"x86_64-apple-darwin\"" | ||
echo " * \"aarch64-unknown-linux-gnu\"" | ||
echo " * \"x86_64-unknown-linux-gnu\"" | ||
echo " * \"x86_64-pc-windows-msvc\"" | ||
exit 0 | ||
} | ||
|
||
# Options: | ||
# apple-arm64: aarch64-apple-darwin | ||
# apple-x86: x86_64-apple-darwin | ||
# linux-arm64: aarch64-unknown-linux-gnu | ||
# linux-x86: x86_64-unknown-linux-gnu | ||
# windows-x86: x86_64-pc-windows-msvc | ||
TARGET="" | ||
# --version <version> | ||
VERSION="" | ||
|
||
# Parse command line arguments | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
--target) | ||
TARGET="$2" | ||
shift | ||
shift | ||
;; | ||
--version) | ||
VERSION="$2" | ||
shift | ||
shift | ||
;; | ||
-h|--help) | ||
help | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Check if required arguments are provided | ||
if [ -z "${TARGET}" ]; then | ||
echo "Missing required argument: --target" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$VERSION" ]; then | ||
echo "Missing required argument: --version" | ||
exit 1 | ||
fi | ||
|
||
# Build the project | ||
pip3 install ziglang | ||
cargo install cargo-zigbuild | ||
rustup target add "${TARGET}" | ||
cargo zigbuild --target "${TARGET}" --release | ||
|
||
# Set binary name to typeshare | ||
BINARY_NAME="typeshare" | ||
TARGET_DIR="target/${TARGET}/release" | ||
|
||
# Create zip directory | ||
mkdir -p "dist" | ||
|
||
OUTPUT_DIR="$(pwd)/dist" | ||
|
||
# Create zip file with binary | ||
ZIP_NAME="${BINARY_NAME}-${VERSION}-${TARGET}.zip" | ||
pushd ${TARGET_DIR} && zip "${OUTPUT_DIR}/${ZIP_NAME}" "${BINARY_NAME}${BINARY_SUFFIX}" && popd | ||
|
||
# Create manifest file similar to cargo-dist | ||
echo "{\"artifacts\": [{\"path\": \"dist/${ZIP_NAME}\"}]}" > dist-manifest.json | ||
|
||
echo "Build complete, contents of dist-manifest.json:" | ||
cat dist-manifest.json | ||
|
||
# Upload to release | ||
cat dist-manifest.json | jq --raw-output ".artifacts[]?.path | select( . != null )" > uploads.txt | ||
echo "uploading..." | ||
cat uploads.txt | ||
gh release upload ${VERSION} $(cat uploads.txt) | ||
echo "uploaded!" |