-
Notifications
You must be signed in to change notification settings - Fork 200
95 lines (85 loc) · 4 KB
/
check-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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