Skip to content

Commit c1d586b

Browse files
authored
Merge pull request #16 from joinflux/feature/auto-version-release
feat(ci): add auto version checker
2 parents 1956863 + 553fd10 commit c1d586b

4 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/scripts/create-release.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
NPM_VERSION="$1"
5+
REPO_VERSION="$2"
6+
7+
echo "Comparing versions:"
8+
echo " npm: $NPM_VERSION"
9+
echo " repo: $REPO_VERSION"
10+
11+
if [ "$NPM_VERSION" != "$REPO_VERSION" ]; then
12+
echo "New version detected! Creating release for v$NPM_VERSION"
13+
14+
# Create release notes
15+
cat > release-notes.md << EOF
16+
## Firebase Tools v$NPM_VERSION
17+
18+
This release updates the firebase-tools version to v$NPM_VERSION.
19+
20+
### Changes
21+
- Updated firebase-tools from v$REPO_VERSION to v$NPM_VERSION
22+
23+
### Docker Images
24+
- \`joinflux/firebase-action:$NPM_VERSION\` - Regular Node.js image
25+
- \`joinflux/firebase-action:$NPM_VERSION-alpine\` - Alpine-based image
26+
27+
For firebase-tools changelog, see: https://github.com/firebase/firebase-tools/releases
28+
EOF
29+
30+
# Create the release
31+
gh release create "v$NPM_VERSION" \
32+
--title "v$NPM_VERSION" \
33+
--notes-file release-notes.md
34+
35+
echo "created=true" >> "$GITHUB_OUTPUT"
36+
echo "version=$NPM_VERSION" >> "$GITHUB_OUTPUT"
37+
echo "✅ Successfully created release v$NPM_VERSION"
38+
else
39+
echo "No new version. Current version: $REPO_VERSION"
40+
echo "created=false" >> "$GITHUB_OUTPUT"
41+
fi

.github/scripts/get-npm-version.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Get the latest firebase-tools version from npm
5+
LATEST_VERSION=$(npm view firebase-tools version)
6+
7+
echo "latest=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
8+
echo "Latest firebase-tools version: $LATEST_VERSION"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Get the latest release tag, or use 0.0.0 if no releases exist
5+
LATEST_RELEASE=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || echo "0.0.0")
6+
7+
# Remove 'v' prefix if present
8+
LATEST_RELEASE=${LATEST_RELEASE#v}
9+
10+
echo "latest=$LATEST_RELEASE" >> "$GITHUB_OUTPUT"
11+
echo "Latest repo release: $LATEST_RELEASE"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto Release on Firebase Tools Update
2+
3+
on:
4+
schedule:
5+
# Check for new firebase-tools versions every Monday at 9 AM UTC
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
check-and-release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get latest firebase-tools version from npm
21+
id: npm-version
22+
run: .github/scripts/get-npm-version.sh
23+
24+
- name: Get latest release version from this repo
25+
id: repo-version
26+
run: .github/scripts/get-repo-version.sh
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
30+
- name: Compare versions and create release
31+
id: create-release
32+
run: |
33+
.github/scripts/create-release.sh \
34+
"${{ steps.npm-version.outputs.latest }}" \
35+
"${{ steps.repo-version.outputs.latest }}"
36+
env:
37+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)