diff --git a/.github/workflows/publish_flutter_packages.yaml b/.github/workflows/publish_flutter_packages.yaml new file mode 100644 index 0000000..ebde908 --- /dev/null +++ b/.github/workflows/publish_flutter_packages.yaml @@ -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 < $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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..03e8c7c --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 "embrace-ci@users.noreply.github.com" + 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 }}"}' diff --git a/.github/workflows/release_candidate_merged.yaml b/.github/workflows/release_candidate_merged.yaml new file mode 100644 index 0000000..e45363e --- /dev/null +++ b/.github/workflows/release_candidate_merged.yaml @@ -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 diff --git a/.github/workflows/release_candidate_pr.yaml b/.github/workflows/release_candidate_pr.yaml new file mode 100644 index 0000000..1b5c05a --- /dev/null +++ b/.github/workflows/release_candidate_pr.yaml @@ -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