get some debug output #130
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
name: brew test and publish bot | |
on: | |
push: | |
branches: | |
- release-* | |
jobs: | |
release: | |
runs-on: macos-latest | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Set up git | |
uses: Homebrew/actions/git-user-config@master | |
- name: Cache Homebrew Bundler RubyGems | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.set-up-homebrew.outputs.gems-path }} | |
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | |
restore-keys: ${{ runner.os }}-rubygems- | |
- name: Install Homebrew Bundler RubyGems | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: brew install-bundler-gems | |
- name: cleanup | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew test-bot --only-cleanup-before | |
- name: setup | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew test-bot --only-setup | |
- name: build earthly bottles (let me see whats happening) | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew test-bot --only-formulae earthly && ls -la | |
- name: shellcheck testing | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: ls earthly--*.bottle.* | |
#| grep bottle | awk -F "--" '{print "mv " $0 " " $1"-"$2}' | |
- name: syntax check | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew test-bot --only-tap-syntax | |
- name: brew update | |
env: | |
HOMEBREW_NO_INSTALL_FROM_API: 1 | |
run: brew update | |
- name: build earthly bottles | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew test-bot --only-formulae earthly | |
# homebrew intentially adds in two hyphens under | |
# https://github.com/Homebrew/brew/blob/b55498269f1fb0380cfd7122f6bbc0fc0125c35f/Library/Homebrew/software_spec.rb#L279 | |
- name: remove double hyphens which are produced by test-bot | |
run: ls earthly--* | grep bottle | awk -F "--" '{print "mv " $0 " " $1"-"$2}' | sh | |
- name: move bottles into bottles/ dir | |
run: mkdir bottles/ && mv *.bottle.* bottles/ | |
- name: merge bottles | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} | |
run: brew bottle --merge --root-url "https://github.com/$GITHUB_REPOSITORY/releases/download/" --write bottles/*.json | |
# "brew test-bot" removes dependencies; we must re-install them here | |
- name: (re)install dependencies | |
run: brew install jq npm | |
- name: setup github-release | |
run: npm install -g [email protected] | |
- name: release bottles | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: |- | |
set -e | |
VERSION="${GITHUB_REF#refs/heads/release-v}" | |
if ! echo $VERSION | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' >/dev/null; then | |
echo "ERROR: failed to detect semantic version; got $VERSION" | |
exit 1 | |
fi | |
RELEASE_TAG="earthly-$VERSION" | |
# first delete any previously released files (needed in case the previous upload attempt failed) | |
PREV_RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$RELEASE_TAG" | jq .id) | |
if [ -n "$PREV_RELEASE_ID" ] && [ "$PREV_RELEASE_ID" != "null" ]; then | |
echo "deleting previous release ID $PREV_RELEASE_ID" | |
curl -s -H "Authorization: token $GITHUB_TOKEN" --request DELETE "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$PREV_RELEASE_ID" | |
fi | |
# next make sure any previous tag is deleted (otherwise github will create an untagged release name vX.Y.Z) | |
echo "deleting tag $RELEASE_TAG (in case it already exists)" | |
curl -s -H "Authorization: token $GITHUB_TOKEN" --request DELETE "https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/tags/$RELEASE_TAG" | |
GITHUB_OWNER=$(dirname "$GITHUB_REPOSITORY") | |
GITHUB_REPO=$(basename "$GITHUB_REPOSITORY") | |
github-release upload \ | |
--owner "$GITHUB_OWNER" \ | |
--repo "$GITHUB_REPO" \ | |
--prerelease false \ | |
--commitish "$GITHUB_SHA" \ | |
--tag "$RELEASE_TAG" \ | |
--name "$RELEASE_TAG" \ | |
--body "earthly: update $VERSION bottle." \ | |
./bottles/*.tar.gz 2>&1 | tee /tmp/release.log | |
if grep -i error /tmp/release.log > /dev/null; then | |
echo "ERROR: github-release upload failed: check the above release.log output" && exit 1 | |
fi | |
- name: merge into main and delete release branch | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: |- | |
# this should be different than GITHUB_SHA, due to brew bottle comitting a change | |
SHA=$(git rev-parse HEAD) | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git fetch -a | |
git checkout main | |
git reset --hard origin/main | |
git merge "$SHA" | |
git push origin main | |
git push origin --delete "$GITHUB_REF" | |
curl -s -X POST -H 'Content-type: application/json' --data '{"text":"homebrew-earthly: Successfully merged release branch into main"}' "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" | |
- name: post to slack on failure | |
run: |- | |
curl -s -X POST -H 'Content-type: application/json' --data '{ "attachments": [ { "fallback": "Failed to build release", "title": "earthly/homebrew-earthly tap", "title_link": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID", "text": "Failed to build release!", "color": "#CC0000" } ] }' "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" | |
if: ${{ failure() }} |