bump #122
Workflow file for this run
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
on: | |
push: | |
tags: | |
- v* | |
permissions: | |
contents: write | |
name: make-release | |
jobs: | |
makerelease: | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest] | |
name: make release | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/[email protected]' | |
with: | |
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}' | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: kittycadapi | |
- name: Install latest nightly | |
uses: dtolnay/rust-toolchain@stable | |
- if: ${{ matrix.os == 'ubuntu-latest' }} | |
name: Install deps | |
shell: bash | |
run: | | |
./.github/workflows/cross-deps.sh | |
- if: ${{ matrix.os == 'macos-latest' }} | |
name: Install deps | |
shell: bash | |
run: | | |
brew install \ | |
coreutils \ | |
jq | |
cargo install toml-cli | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo build | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Run make cross | |
run: | | |
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" | |
make release | |
ls -la cross | |
shell: bash | |
- name: move files to dir for upload | |
shell: bash | |
run: | | |
export VERSION=v$(toml get Cargo.toml package.version | jq -r .) | |
mkdir -p releases/$(basename $(pwd)) | |
cp -r cross releases/$(basename $(pwd))/${VERSION} | |
cp cross/README.md cross/${{matrix.os}}-${{github.ref_name}}-README.md | |
- name: 'upload binary files' | |
id: upload-files | |
uses: google-github-actions/[email protected] | |
with: | |
path: releases | |
destination: dl.kittycad.io | |
# Store the binary artifacts for retrival later. | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ matrix.os }}-${{github.ref_name}} | |
path: ./cross | |
# Store the readme as an artifact so we can combine the two. | |
- name: Archive the README.md data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.os}}-${{github.ref_name}}-README.md | |
path: ${{github.workspace}}/cross/${{matrix.os}}-${{github.ref_name}}-README.md | |
createrelease: | |
runs-on: ubuntu-latest | |
needs: [makerelease] | |
name: createrelease | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install latest nightly | |
uses: dtolnay/rust-toolchain@stable | |
- uses: actions/download-artifact@v4 | |
with: | |
name: release-macos-latest-${{github.ref_name}} | |
path: build | |
- uses: actions/download-artifact@v4 | |
with: | |
name: release-ubuntu-latest-${{github.ref_name}} | |
path: build | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ubuntu-latest-${{github.ref_name}}-README.md | |
- uses: actions/download-artifact@v4 | |
with: | |
name: macos-latest-${{github.ref_name}}-README.md | |
- name: combine readmes | |
shell: bash | |
run: | | |
ls -la | |
echo 'These instructions are meant as an easy way to install. Note: you likely need to install `coreutils` in order to have the `sha256sum` command.' > release.md | |
echo "" >> release.md | |
cat macos-latest-${{github.ref_name}}-README.md \ | |
ubuntu-latest-${{github.ref_name}}-README.md \ | |
>> release.md | |
rm build/*-README.md | |
rm build/README.md | |
- name: Get if prerelease | |
shell: bash | |
id: extract_prerelease | |
run: | | |
cargo install toml-cli | |
export VERSION=v$(toml get Cargo.toml package.version | jq -r .) | |
if echo $VERSION | grep -q "rc"; then | |
echo "##[set-output name=prerelease;]$(echo true)"; | |
else | |
if echo $VERSION | grep -q "pre"; then | |
echo "##[set-output name=prerelease;]$(echo true)"; | |
else | |
echo "##[set-output name=prerelease;]$(echo false)"; | |
fi | |
fi | |
- name: Create a Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: ${{github.workspace}}/release.md | |
prerelease: ${{steps.extract_prerelease.outputs.prerelease}} | |
files: ./build/* | |
createhomebrew: | |
runs-on: ubuntu-latest | |
needs: [makerelease] | |
name: createhomebrew | |
steps: | |
- uses: actions/checkout@master | |
- name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/[email protected]' | |
with: | |
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}' | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: kittycadapi | |
- name: Install deps | |
shell: bash | |
run: | | |
./.github/workflows/cross-deps.sh | |
- name: bundle binaries and make formula | |
shell: bash | |
run: | | |
mkdir homebrew | |
cp homebrew-template.rb homebrew/kittycad.rb | |
input_names=( | |
"x86_64-apple-darwin" | |
"aarch64-apple-darwin" | |
"x86_64-unknown-linux-musl" | |
"aarch64-unknown-linux-musl" | |
) | |
homebrew_names=( | |
"x86_64_darwin" | |
"aarch64_darwin" | |
"x86_64_linux" | |
"aarch64_linux" | |
) | |
to_zip_files="" | |
version=v$(toml get Cargo.toml package.version | jq -r .) | |
sed -i "s#replace-semver#$version#g" "./homebrew/kittycad.rb" | |
for i in "${!input_names[@]}"; do | |
input_name="${input_names[$i]}" | |
homebrew_name="${homebrew_names[$i]}" | |
mkdir "./homebrew/$homebrew_name" | |
curl -L "https://dl.zoo.dev/releases/cli/$version/zoo-$input_name" -o "./homebrew/$homebrew_name/zoo" | |
sha256=$(sha256sum "./homebrew/$homebrew_name/zoo") | |
hash=$(printf '%s\n' "$sha256" | cut -d' ' -f1) | |
sed -i "s#replace-$homebrew_name-sha#$hash#g" "./homebrew/kittycad.rb" | |
to_zip_files="$to_zip_files $homebrew_name/zoo" | |
done | |
(cd ./homebrew && tar -czvf kittycad-cli.tar.gz $to_zip_files) | |
sha256=$(sha256sum "./homebrew/kittycad-cli.tar.gz") | |
hash=$(printf '%s\n' "$sha256" | cut -d' ' -f1) | |
sed -i "s#replace-tarball-sha#$hash#g" "./homebrew/kittycad.rb" | |
# clean up | |
for homebrew_name in "${homebrew_names[@]}"; do | |
rm -rf "./homebrew/$homebrew_name" | |
done | |
# verify output, debug code remove later. | |
echo "tarball and formula" | |
(cd ./homebrew && ls) | |
echo "formula contents" | |
cat ./homebrew/kittycad.rb | |
- name: move files to dir for upload | |
shell: bash | |
run: | | |
export VERSION=v$(toml get Cargo.toml package.version | jq -r .) | |
mkdir -p releases/$(basename $(pwd)) | |
cp -r homebrew releases/$(basename $(pwd))/${VERSION} | |
- name: 'upload binary files' | |
id: upload-files | |
uses: google-github-actions/[email protected] | |
with: | |
path: releases | |
destination: dl.kittycad.io | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
# required | |
app-id: ${{ secrets.GH_ORG_APP_ID }} | |
private-key: ${{ secrets.GH_ORG_APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'kittycad/homebrew-kittycad' | |
path: 'homebrew-kittycad' | |
token: ${{ steps.app-token.outputs.token }} | |
- name: 'replacing Formula/kittycad.rb with ./hombrew/kittycad.rb' | |
shell: bash | |
run: | | |
cp ./homebrew/kittycad.rb homebrew-kittycad/Formula/kittycad.rb | |
- name: commit the changes in the repo | |
shell: bash | |
run: | | |
cd homebrew-kittycad | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -am "YOYO BREW FORMULAR! 🍻" || exit 0 | |
git fetch origin | |
git rebase origin/main || exit 0 | |
export NEW_BRANCH="update-tap-formula" | |
git checkout -b "$NEW_BRANCH" | |
git push -f origin "$NEW_BRANCH" | |
gh pr create --title "Update tap formula" \ | |
--body "Updating the formular for our homebrew tap" \ | |
--head "$NEW_BRANCH" \ | |
--base main || true | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |