Check for firebase-tools releases #16
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: Check for firebase-tools releases | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
check-releases: | |
runs-on: ubuntu-latest | |
outputs: | |
# A semver comparison result - We are the base, firebase-tools is the compare-to | |
comparison: ${{ steps.compare_versions.outputs.comparison-result }} | |
firebase-actions-release: ${{ fromJSON(steps.get_our_release.outputs.data).tag_name }} | |
firebase-tools-release: ${{ fromJSON(steps.get_their_release.outputs.data).tag_name }} | |
steps: | |
- name: Check our latest release | |
uses: octokit/[email protected] | |
id: get_our_release | |
with: | |
route: GET /repos/${{ github.REPOSITORY }}/releases/latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check latest firebase-tools release | |
uses: octokit/[email protected] | |
id: get_their_release | |
with: | |
route: GET /repos/firebase/firebase-tools/releases/latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: madhead/semver-utils@latest | |
id: compare_versions | |
with: | |
# A version to work with | |
version: "${{ fromJSON(steps.get_our_release.outputs.data).tag_name }}" | |
# A version to compare against | |
compare-to: "${{ fromJSON(steps.get_their_release.outputs.data).tag_name }}" | |
- name: Print our release version | |
run: echo "Our latest release is ${{ fromJSON(steps.get_our_release.outputs.data).tag_name }}" | |
- name: Print their release version | |
run: echo "Their latest release is ${{ fromJSON(steps.get_their_release.outputs.data).tag_name }}" | |
- name: Print the result | |
run: echo "${{ fromJSON(steps.get_our_release.outputs.data).tag_name }} ${{ steps.compare_versions.outputs.comparison-result }} ${{ fromJSON(steps.get_their_release.outputs.data).tag_name }}" | |
bump-version: | |
needs: check-releases | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
if: ${{ needs.check-releases.outputs.comparison == '<' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: "master" | |
- name: Remove leading 'v' from version numbers | |
run: | | |
FIREBASE_ACTIONS_RELEASE=${{ needs.check-releases.outputs.firebase-actions-release }} | |
FIREBASE_TOOLS_RELEASE=${{ needs.check-releases.outputs.firebase-tools-release }} | |
echo "FIREBASE_ACTIONS_RELEASE=${FIREBASE_ACTIONS_RELEASE#v}" >> $GITHUB_ENV | |
echo "FIREBASE_TOOLS_RELEASE=${FIREBASE_TOOLS_RELEASE#v}" >> $GITHUB_ENV | |
- name: Bump version | |
id: bump-version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "${{ env.FIREBASE_ACTIONS_RELEASE }}" | |
replace: "${{ env.FIREBASE_TOOLS_RELEASE }}" | |
include: "{Dockerfile,action.yaml}" | |
regex: false | |
- name: Commit & Push changes | |
if: ${{ steps.bump-version.outputs.modifiedFiles > 0 }} | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -a -m "Bump firebase-tools to ${{ needs.check-releases.outputs.firebase-tools-release }}" | |
git tag -a ${{ needs.check-releases.outputs.firebase-tools-release }} -m "Bump firebase-tools to ${{ needs.check-releases.outputs.firebase-tools-release }}" | |
git push origin HEAD:master --tags | |
- name: Create Release | |
id: create_release | |
uses: comnoco/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: ${{ needs.check-releases.outputs.firebase-tools-release }} | |
release_name: firebase-tools ${{ needs.check-releases.outputs.firebase-tools-release }} | |
body: "Bump `firebase-tools` to ${{ needs.check-releases.outputs.firebase-tools-release }}" | |
draft: false | |
prerelease: false |