refactor: add bin for bunx (#11) #27
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
name: Release | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
release: | |
name: Generate Release | |
runs-on: ubuntu-latest | |
outputs: | |
release_created: ${{ steps.release.outputs.release_created }} | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Release | |
uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
token: ${{ secrets.RELEASE_TOKEN }} | |
release-type: node | |
- name: Set version | |
id: version | |
if: ${{ steps.release.outputs.release_created }} | |
run: echo "VERSION=${{ steps.release.outputs.tag_name }}" | sed 's/^v//' >> $GITHUB_ENV | |
build_and_upload: | |
name: Build and Upload Artifacts | |
runs-on: ubuntu-latest | |
needs: release | |
if: needs.release.outputs.release_created == 'true' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Set version | |
run: | | |
VERSION=${{ needs.release.outputs.tag_name }} | |
VERSION=${VERSION#v} | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Build and package artifacts | |
run: | | |
declare -A targets=( | |
["linux-x64"]="bun-linux-x64-modern" | |
["darwin-arm64"]="bun-darwin-arm64" | |
["darwin-amd64"]="bun-darwin-x64-modern" | |
["windows-amd64"]="bun-windows-x64-modern" | |
) | |
for target in "${!targets[@]}"; do | |
bun build --compile --minify --target="${targets[$target]}" src/cli.ts --outfile "tilepack" | |
if [[ "$target" == "windows-amd64" ]]; then | |
mv tilepack tilepack.exe | |
tar -czvf "tilepack-${VERSION}-${target}.tar.gz" tilepack.exe | |
else | |
tar -czvf "tilepack-${VERSION}-${target}.tar.gz" tilepack | |
fi | |
done | |
- name: Upload Release Artifact | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
run: | | |
gh release upload ${{ needs.release.outputs.tag_name }} \ | |
tilepack-${VERSION}-linux-x64.tar.gz \ | |
tilepack-${VERSION}-darwin-arm64.tar.gz \ | |
tilepack-${VERSION}-darwin-amd64.tar.gz \ | |
tilepack-${VERSION}-windows-amd64.tar.gz | |
brew_release: | |
name: Homebrew Release | |
runs-on: ubuntu-latest | |
needs: build_and_upload | |
if: needs.release.outputs.release_created == 'true' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Brew Release | |
uses: Justintime50/homebrew-releaser@v1 | |
with: | |
commit_owner: eknowles | |
commit_email: 817611+eknowles@users.noreply.github.com | |
github_token: ${{ secrets.RELEASE_TOKEN }} | |
homebrew_owner: eknowles | |
homebrew_tap: homebrew-tools | |
install: 'bin.install "tilepack" => "tilepack"' | |
test: 'assert_match("tilepack #{version}", shell_output("#{bin}/tilepack --version"))' | |
target_darwin_amd64: true | |
target_darwin_arm64: true | |
target_linux_amd64: true | |
update_readme_table: true | |
debug: true |