Skip to content

Commit 2b1bc5f

Browse files
authored
Evancoleman/fixes release (#51)
* fixes * move some logic directly into actions
1 parent b20cea4 commit 2b1bc5f

File tree

5 files changed

+256
-211
lines changed

5 files changed

+256
-211
lines changed

.github/workflows/build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'releases/**'
8+
9+
jobs:
10+
build:
11+
runs-on: macos-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Extract version from branch name
17+
id: extract_version
18+
run: |
19+
branch_name=${{ github.ref_name }}
20+
if [[ "$branch_name" == release/* ]]; then
21+
version=${branch_name#release/}
22+
echo "Version: $version"
23+
echo "::set-output name=version::${version}"
24+
else
25+
echo "Not a release branch."
26+
exit 1
27+
fi
28+
29+
- name: Download release artifact
30+
id: download_artifact
31+
run: |
32+
artifact_name="Firebase.zip"
33+
34+
echo "Downloading artifact from $REPO version $VERSION"
35+
36+
# Get the release ID for the specific version
37+
release_id=$(gh api repos/$REPO/releases/tags/$VERSION --jq '.id')
38+
39+
# Get release notes
40+
release_notes=$(gh release view $release_id --repo $REPO --json body | jq -r '.body')
41+
echo "::set-output name=release_notes::${release_notes}"
42+
43+
# Download the release artifact for that release ID
44+
gh release download $release_id --repo $REPO --pattern $artifact_name --dir ./
45+
env:
46+
REPO: firebase/firebase-ios-sdk
47+
VERSION: ${{ steps.extract_version.outputs.version }}
48+
49+
- name: Package release
50+
run: |
51+
cd .scripts
52+
sh ./package.sh
53+
54+
git add .
55+
git commit -m "Updated Package.swift and sources for latest firebase sdks"
56+
git push -u origin release/$VERSION
57+
env:
58+
VERSION: ${{ steps.extract_version.outputs.version }}
59+
60+
- name: Upload artifacts
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: Firebase
64+
path: artifacts/*
65+
66+
- name: Open pull request
67+
run: |
68+
gh pr create --title "Update to Firebase $VERSION" --body "$RELEASE_NOTES" --base main --head release/$VERSION
69+
echo "::set-output name=number::${number}"
70+
env:
71+
VERSION: ${{ steps.extract_version.outputs.version }}
72+
RELEASE_NOTES: ${{ steps.download_artifact.outputs.release_notes }}
73+
74+
- name: Approve pull request
75+
run: |
76+
gh pr review --approve
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.AFRESHY_PAT }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Create Release Branch
2+
3+
on:
4+
schedule:
5+
# Every day at 05:00 EST (10:00 UTC)
6+
- cron: '0 10 * * *'
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Get latest Firebase release
16+
id: latest_firebase_release
17+
run: |
18+
latest_firebase_release=$(gh release view --repo $REPO --json tagName --jq '.tagName')
19+
echo "::set-output name=latest_firebase_release::${latest_firebase_release}"
20+
env:
21+
REPO: firebase/firebase-ios-sdk
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Check if branch exists
25+
id: check_branch
26+
run: |
27+
git fetch origin
28+
29+
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
30+
echo "::set-output name=branch_exists::true"
31+
else
32+
echo "::set-output name=branch_exists::false"
33+
fi
34+
env:
35+
BRANCH: release/${{ steps.latest_firebase_release.outputs.latest_firebase_release }}
36+
37+
- name: Create release branch
38+
if: steps.check_branch.outputs.branch_exists == 'false'
39+
run: |
40+
git checkout -b $BRANCH
41+
git push origin $BRANCH
42+
env:
43+
BRANCH: release/${{ steps.latest_firebase_release.outputs.latest_firebase_release }}

.github/workflows/package.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release Version
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Get latest Firebase release
16+
id: latest_firebase_release
17+
run: |
18+
version=$(gh release view --repo $REPO --json tagName --jq '.tagName')
19+
echo "::set-output name=version::${version}"
20+
env:
21+
REPO: firebase/firebase-ios-sdk
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Check if release exists
25+
id: check_release
26+
run: |
27+
echo "Checking if release $version exists..."
28+
29+
# Check if the release exists by querying the GitHub API
30+
if gh api repos/${{ github.repository }}/releases/tags/$VERSION --silent; then
31+
echo "Release $VERSION exists."
32+
echo "::set-output name=exists::true"
33+
else
34+
echo "Release $VERSION does not exist."
35+
echo "::set-output name=exists::false"
36+
fi
37+
env:
38+
VERSION: ${{ steps.latest_firebase_release.outputs.version }}
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
42+
- name: Download artifacts from latest build run
43+
if: steps.check_release.outputs.exists == 'false'
44+
run: |
45+
branch_name=release/$VERSION
46+
workflow_name="Build Release"
47+
48+
echo "Getting build workflow run for branch: $branch_name"
49+
50+
# Get the latest workflow run ID for the branch
51+
run_id=$(gh api repos/${{ github.repository }}/actions/runs \
52+
--paginate \
53+
--jq ".workflow_runs[] | select(.head_branch == \"$branch_name\" and .name == \"$workflow_name\") | .id" | head -n 1)
54+
55+
56+
if [ -z "$run_id" ]; then
57+
echo "No build workflow run found for branch $branch_name"
58+
exit 1
59+
else
60+
echo "Found build workflow run ID: $run_id"
61+
fi
62+
63+
# Download all artifacts from the workflow run
64+
gh run download $run_id --repo ${{ github.repository }} --dir ./artifacts/
65+
env:
66+
VERSION: ${{ steps.latest_firebase_release.outputs.version }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Create release and upload artifacts
70+
run: |
71+
echo "Creating a release for version $version"
72+
73+
firebase_release_id=$(gh api repos/$FIREBASE_REPO/releases/tags/$VERSION --jq '.id')
74+
release_notes=$(gh release view $release_id --repo $FIREBASE_REPO --json body | jq -r '.body')
75+
76+
# Create a new release
77+
gh release create $version ./artifacts/* \
78+
--title "$version" \
79+
--notes "$release_notes"
80+
env:
81+
FIREBASE_REPO: firebase/firebase-ios-sdk
82+
VERSION: ${{ steps.latest_firebase_release.outputs.version }}
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
85+

0 commit comments

Comments
 (0)