This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from advancedtelematic/feat/ci-for-bottle-buil…
…ding Add ci to build homebrew bottle automatically
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build macOS homebrew bottle for ota-cli release page | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
macOS: | ||
name: Build macOS homebrew bottle for ota-cli release page | ||
runs-on: macOS-10.14 | ||
steps: | ||
- name: Attempt to auto-update recipe and build bottle | ||
run: | | ||
curl -O https://raw.githubusercontent.com/advancedtelematic/homebrew-otaconnect/master/ota.rb | ||
VERSION=$(basename $GITHUB_REF) | ||
RELEASE_URL="https://github.com/advancedtelematic/ota-cli/releases/download/${VERSION}/" | ||
sed -i '' -E "s/ version \"[0-9]+.[0-9]+.[0-9]+\"/ version \"${VERSION}\"/" ota.rb | ||
brew install --build-bottle ./ota.rb | ||
brew bottle --json --no-rebuild --force-core-tap --root-url=${RELEASE_URL} ota | ||
brew bottle --merge --write --no-commit ./ota--${VERSION}.mojave.bottle.json | ||
rm ota.rb | ||
echo "Bottle and recipe creation succeeded!" | ||
echo "You should now open a PR at https://github.com/advancedtelematic/homebrew/otaconnect" | ||
echo "Here's the new recipe. It's also attached to this job as an artifact." | ||
echo "------------------------------------------------------------------------------------" | ||
brew cat ota | tee ota.rb | ||
echo "------------------------------------------------------------------------------------" | ||
mv ota--${VERSION}.mojave.bottle.tar.gz ota-${VERSION}.mojave.bottle.tar.gz | ||
- name: Upload bottle to github release page | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
VERSION=$(basename $GITHUB_REF) | ||
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH) | ||
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" | ||
FILENAME=ota-${VERSION}.mojave.bottle.tar.gz | ||
UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}" | ||
curl -sSL -H "${AUTH_HEADER}" -F "data=@${FILENAME}" "$UPLOAD_URL" | ||
- name: Save recipe as build artifact | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: ota.rb | ||
path: ota.rb |