-
Notifications
You must be signed in to change notification settings - Fork 200
149 lines (130 loc) · 5.32 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
outputs:
new-version: ${{ needs.check-releases.outputs.firebase-tools-release }}
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
# - id: set-version
# run: echo "version=${{env.FIREBASE_TOOLS_RELEASE}}" >> "$GITHUB_OUTPUT"
- 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.RELEASE_TOKEN }} # Can't use a GITHUB_TOKEN for this or other actions won't be triggered on a new release
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
publish:
name: Docker build & push
needs: bump-version
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v3
with:
ref: ${{ needs.bump-version.outputs.new-version }}
-
name: Get Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
tags: |
${{ needs.bump-version.outputs.new-version }}
latest
images: |
w9jds/firebase-action
ghcr.io/${{ github.repository }}
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: w9jds
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}