Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflows #14

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/publish_flutter_packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish Package

on:
workflow_dispatch:
inputs:
dry-run:
description: 'Validate but do not push the package'
type: boolean
required: true
workflow_call:
inputs:
dry-run:
description: 'Validate but do not push the package'
type: boolean
required: true

jobs:
publish:
name: Publish Package

runs-on: ubuntu-latest
timeout-minutes: 20

strategy:
matrix:
package: ['embrace_platform_interface', 'embrace_ios', 'embrace_android', 'embrace', 'embrace_dio']
fail-fast: true
max-parallel: 1 # Publish the packages in sequential order

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4

- name: 🐦 Setup Flutter
uses: embrace-io/flutter-action@v2
with:
flutter-version: '3.3.1'
channel: stable
cache: true

- name: Get Publishing Credentials
run: |
mkdir -p $XDG_CONFIG_HOME/dart
cat <<EOF > $XDG_CONFIG_HOME/dart/pub-credentials.json
${{ secrets.FLUTTER_PUB_CREDENTIALS }}
EOF

- name: Publish Dry Run
run: |
cd ${{ matrix.package }}
flutter config --no-analytics
flutter pub publish --dry-run

- name: Publish
if: ${{ inputs.dry-run == false }}
run: |
cd ${{ matrix.package }}
flutter pub publish -f
98 changes: 98 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release

env:
REPO_PATH: 'embrace-flutter-sdk'
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
workflow_dispatch:
inputs:
dry-run:
description: 'Validate but do not push the package'
type: boolean
required: true
workflow_call:
inputs:
dry-run:
description: 'Validate but do not push the package'
type: boolean
required: true

permissions:
contents: write
packages: write

jobs:
verify-versions:
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
path: ${{ env.REPO_PATH }}

- name: Setup yq
run: |
sudo snap install yq

- name: Verify Package Versions
run: |
cd ${{ env.REPO_PATH }}
./verify_versions.sh

publish-packages:
name: Publish Packages
needs: verify-versions
uses: ./.github/workflows/publish_flutter_packages.yaml
with:
dry-run: ${{ inputs.dry-run }}
secrets: inherit

create-release:
name: Create Release
needs: publish-packages
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
path: ${{ env.REPO_PATH }}

- name: Setup yq
run: |
sudo snap install yq

- name: Parse Version
run: |
cd ${{ env.REPO_PATH }}
export PACKAGE_VERSION=$(yq -r .version embrace/pubspec.yaml)
echo "${PACKAGE_VERSION}"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV

- name: Tag commit
run: |
cd ${{ env.REPO_PATH }}
git config --global user.name "embrace-ci"
git config --global user.email "[email protected]"
git tag -a ${{ env.PACKAGE_VERSION }} -m "${{ env.PACKAGE_VERSION }}"

- name: Push Tag
if: ${{ inputs.dry-run == false }}
run: |
cd ${{ env.REPO_PATH }}
git push --tags

- name: Create Release
if: ${{ inputs.dry-run == false }}
run: |
cd ${{ env.REPO_PATH }}
gh release create ${{ env.PACKAGE_VERSION }} -t ${{ env.PACKAGE_VERSION }} -F embrace/CHANGELOG.md

- name: Record SDK Version History
if: ${{ inputs.dry-run == false }}
run: |
curl -X POST ${{ vars.SDK_VERSION_URL }}/flutter/version/ -H 'X-Embrace-CI: ${{ secrets.SDK_VERSION_TOKEN }}' -H 'Content-Type: application/json' -d '{"version": "${{ env.PACKAGE_VERSION }}"}'
16 changes: 16 additions & 0 deletions .github/workflows/release_candidate_merged.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Invokes the release workflow whenever a release candidate PR is merged
name: RC Release

on:
pull_request:
types:
- closed

jobs:
publish:
if: contains(github.event.pull_request.labels.*.name, 'release-candidate') && github.event.pull_request.merged == true
name: Publish Release
uses: ./.github/workflows/release.yaml
with:
dry-run: false
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/release_candidate_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Invokes the release workflow in dry-run mode whenever a release candidate PR is opened or updated
name: RC-PR

on: pull_request

jobs:

rc-publish-dry-run:
name: Publish Release (dry-run)
if: contains(github.event.pull_request.labels.*.name, 'release-candidate')
uses: ./.github/workflows/release.yaml
with:
dry-run: true
secrets: inherit
Loading