Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,35 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" "${{ steps.pkg.outputs.archive }}" \
--title "${GITHUB_REF_NAME}" \
--generate-notes
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" "${{ steps.pkg.outputs.archive }}" --clobber
else
gh release create "${GITHUB_REF_NAME}" "${{ steps.pkg.outputs.archive }}" \
--title "${GITHUB_REF_NAME}" \
--generate-notes
fi

- name: Update sangdth/homebrew-tap Formula/lodo.rb
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
VERSION: ${{ steps.pkg.outputs.version }}
TAG: ${{ github.ref_name }}
ARCHIVE: ${{ steps.pkg.outputs.archive }}
SHA256: ${{ steps.pkg.outputs.sha256 }}
REPO: ${{ github.repository }}
run: |
if [ -z "${TAP_TOKEN}" ]; then
echo "HOMEBREW_TAP_TOKEN is unset: skipping the tap update"
exit 0
if [ -z "${TAP_DEPLOY_KEY}" ]; then
echo "HOMEBREW_TAP_DEPLOY_KEY is unset" >&2
exit 1
fi
KEY_DIR="$(mktemp -d)"
TAP_DIR="$(mktemp -d)"
git clone "https://x-access-token:${TAP_TOKEN}@github.com/sangdth/homebrew-tap.git" "${TAP_DIR}"
trap 'rm -rf "${KEY_DIR}" "${TAP_DIR}"' EXIT
printf '%s\n' "${TAP_DEPLOY_KEY}" > "${KEY_DIR}/id_ed25519"
chmod 600 "${KEY_DIR}/id_ed25519"
ssh-keyscan -t ed25519 github.com > "${KEY_DIR}/known_hosts" 2>/dev/null
export GIT_SSH_COMMAND="ssh -i ${KEY_DIR}/id_ed25519 -o IdentitiesOnly=yes -o UserKnownHostsFile=${KEY_DIR}/known_hosts -o StrictHostKeyChecking=yes"
git clone "git@github.com:sangdth/homebrew-tap.git" "${TAP_DIR}"
mkdir -p "${TAP_DIR}/Formula"
cat > "${TAP_DIR}/Formula/lodo.rb" <<EOF
class Lodo < Formula
Expand Down Expand Up @@ -101,5 +111,5 @@ jobs:
git -C "${TAP_DIR}" add Formula/lodo.rb
if ! git -C "${TAP_DIR}" diff --cached --quiet; then
git -C "${TAP_DIR}" commit -m "chore: bump lodo to ${TAG}"
git -C "${TAP_DIR}" push origin HEAD
git -C "${TAP_DIR}" push -u origin HEAD
fi
Loading