mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Add automatic deployment for homebrew releases (and prereleases) (#1111)
This new job will submit a PR to the relevant upstream repo as part of the release workflow. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
b71b6a99f3
commit
4adbe5e29a
1 changed files with 127 additions and 8 deletions
135
.github/workflows/release.yaml
vendored
135
.github/workflows/release.yaml
vendored
|
@ -14,6 +14,7 @@ jobs:
|
|||
- name: Validate version
|
||||
run: |
|
||||
JRNL_VERSION="${{ github.event.inputs.version }}"
|
||||
echo "::debug::version: $JRNL_VERSION"
|
||||
if [[ ! $JRNL_VERSION =~ ^v[0-9]+(\.[0-9]+){1,2}(-(alpha|beta)(\.[0-9]+)?)?$ ]]; then
|
||||
echo
|
||||
echo "::error::Bad version"
|
||||
|
@ -29,13 +30,15 @@ jobs:
|
|||
echo " v2.5.1-beta"
|
||||
exit 1
|
||||
fi
|
||||
echo "::debug::version: $JRNL_VERSION"
|
||||
echo "JRNL_VERSION=$JRNL_VERSION" >> $GITHUB_ENV
|
||||
|
||||
release_pypi:
|
||||
needs: validate
|
||||
name: "Release to PyPI"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
pypi_version: ${{ steps.pypi-version-getter.outputs.pypi_version }}
|
||||
env:
|
||||
HOME_REPO: ${{ secrets.HOME_REPO }}
|
||||
steps:
|
||||
- name: Get version
|
||||
run: |
|
||||
|
@ -48,10 +51,16 @@ jobs:
|
|||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
|
||||
- name: Config git user
|
||||
run: |
|
||||
git config --global user.name "${{ secrets.JRNL_BOT_NAME }}"
|
||||
git config --global user.email "${{ secrets.JRNL_BOT_EMAIL }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install poetry
|
||||
|
||||
|
@ -61,17 +70,127 @@ jobs:
|
|||
echo __version__ = \"$JRNL_VERSION\" > jrnl/__version__.py
|
||||
|
||||
- name: Commit updated files
|
||||
if: ${{ github.repository == env.HOME_REPO }}
|
||||
run: |
|
||||
git config user.email "jrnl.bot@gmail.com"
|
||||
git config user.name "Jrnl Bot"
|
||||
git add pyproject.toml jrnl/__version__.py
|
||||
git commit -m "Increment version to ${JRNL_VERSION}"
|
||||
git tag -a -m "$JRNL_VERSION" "$JRNL_VERSION"
|
||||
git push origin develop --tags
|
||||
git push --tags
|
||||
|
||||
- name: Build
|
||||
run: poetry build
|
||||
|
||||
- name: Deploy to PyPI
|
||||
if: ${{ github.repository == env.HOME_REPO }}
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
|
||||
run: |
|
||||
poetry publish --build
|
||||
run: poetry publish
|
||||
|
||||
- name: Get PyPI version
|
||||
id: pypi-version-getter
|
||||
run: |
|
||||
pypi_version="$(ls dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')"
|
||||
echo "::set-output name=pypi_version::$pypi_version"
|
||||
|
||||
release_homebrew:
|
||||
needs: release_pypi
|
||||
name: "Release to Homebrew"
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
HOME_REPO: ${{ secrets.HOME_REPO }}
|
||||
steps:
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
JRNL_VERSION="${{ github.event.inputs.version }}"
|
||||
PYPI_VERSION="${{ needs.release_pypi.outputs.pypi_version }}"
|
||||
|
||||
echo "::debug::jrnl version: $JRNL_VERSION"
|
||||
echo "::debug::pypi version: $PYPI_VERSION"
|
||||
|
||||
echo "JRNL_VERSION=$JRNL_VERSION" >> $GITHUB_ENV
|
||||
echo "PYPI_VERSION=$PYPI_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Determine type of release
|
||||
env:
|
||||
REPO_OWNER: ${{ github.repository_owner }}
|
||||
run: |
|
||||
if [[ $JRNL_VERSION =~ (alpha|beta) ]]; then
|
||||
echo '::debug::Prerelease (not a full release)'
|
||||
{
|
||||
echo "RELEASE_TYPE=pre"
|
||||
echo "FORMULA_REPO=${REPO_OWNER}/homebrew-prerelease"
|
||||
echo "BOT_REPO=jrnl-bot/homebrew-prerelease"
|
||||
echo "FORMULA_NAME=jrnl-beta"
|
||||
} >> $GITHUB_ENV
|
||||
else
|
||||
echo '::debug::Full release (not a prerelease)'
|
||||
if [[ "${{ github.repository }}" == "${HOME_REPO}" ]]; then
|
||||
REPO_OWNER="homebrew"
|
||||
fi
|
||||
{
|
||||
echo "RELEASE_TYPE=full"
|
||||
echo "FORMULA_REPO=${REPO_OWNER}/homebrew-core"
|
||||
echo "BOT_REPO=jrnl-bot/homebrew-core"
|
||||
echo "FORMULA_NAME=jrnl"
|
||||
} >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Checkout homebrew repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
repository: ${{ env.FORMULA_REPO }}
|
||||
|
||||
- name: Config git user
|
||||
run: |
|
||||
git config --global user.name "${{ secrets.JRNL_BOT_NAME }}"
|
||||
git config --global user.email "${{ secrets.JRNL_BOT_EMAIL }}"
|
||||
|
||||
- name: Create branch
|
||||
run: |
|
||||
BRANCH_NAME="jrnl-${JRNL_VERSION}--${RANDOM}"
|
||||
git remote rename origin upstream
|
||||
git remote add origin "https://github.com/${BOT_REPO}.git"
|
||||
git fetch origin
|
||||
git checkout -b $BRANCH_NAME
|
||||
git push -u origin $BRANCH_NAME
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew install pipgrip
|
||||
|
||||
- name: Query PyPI API
|
||||
run: curl -Ls https://pypi.org/pypi/jrnl/json > api_response.json
|
||||
|
||||
- name: Update Homebrew Formula
|
||||
run: >
|
||||
brew bump-formula-pr "Formula/${FORMULA_NAME}.rb"
|
||||
--url $(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)
|
||||
--sha256 $(jq ".releases[\"${PYPI_VERSION}\"][1].digests.sha256" -r api_response.json)
|
||||
--version=$PYPI_VERSION
|
||||
--no-audit
|
||||
--write
|
||||
--commit
|
||||
--force
|
||||
|
||||
- name: Update commit message
|
||||
run: |
|
||||
git commit --amend \
|
||||
-m "jrnl ${JRNL_VERSION}" \
|
||||
-m "Update jrnl to ${JRNL_VERSION}" \
|
||||
-m '${{ secrets.RELEASE_COAUTHORS }}'
|
||||
|
||||
- name: Push commit
|
||||
run: |
|
||||
git show head
|
||||
git push
|
||||
|
||||
- name: Open pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
run: >
|
||||
gh pr create
|
||||
--title "jrnl ${JRNL_VERSION}"
|
||||
--body 'Created with `brew bump-formula-pr`.'
|
||||
|
|
Loading…
Add table
Reference in a new issue