diff --git a/.github/workflows/release_github.yml b/.github/workflows/release_github.yml new file mode 100644 index 000000000..bcc905c95 --- /dev/null +++ b/.github/workflows/release_github.yml @@ -0,0 +1,56 @@ +name: release_github + +on: + push: + branches: [master] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + release: + # Only run this job for commits that indicate a release + if: "${{ startsWith(github.event.head_commit.message, 'chore(repo): release') }}" + runs-on: ubuntu-latest + + steps: + - name: 📚 Checkout branch + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: đŸˇī¸ Extract Version Tag + id: extract_tag + shell: bash + run: | + set -euo pipefail + + commit_msg="${{ github.event.head_commit.message }}" + echo "đŸ“Ļ Commit message: $commit_msg" + + # Match vX.Y.Z or vX.Y.Z-suffix (case-insensitive) + version_regex='[vV][0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.\-]+)?' + + if [[ "$commit_msg" =~ $version_regex ]]; then + version="${BASH_REMATCH[0]}" + is_prerelease=$([[ $version == *-* ]] && echo true || echo false) + + echo "✅ Found version tag: $version" + echo "â„šī¸ Pre-release: $is_prerelease" + + echo "tag=$version" >> "$GITHUB_OUTPUT" + echo "prerelease=$is_prerelease" >> "$GITHUB_OUTPUT" + else + echo "::error ::❌ No SemVer tag found in commit message." + echo "::error ::Expected something like: 'chore(repo): release v1.2.3[-beta]'" + exit 1 + fi + + - name: 🚀 Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + tag_name: ${{ steps.extract_tag.outputs.tag }} + prerelease: ${{ steps.extract_tag.outputs.prerelease }} + token: ${{ secrets.BOT_GITHUB_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_pub.yml b/.github/workflows/release_pub.yml new file mode 100644 index 000000000..c99f9a8f4 --- /dev/null +++ b/.github/workflows/release_pub.yml @@ -0,0 +1,39 @@ +name: release_pub + +on: + release: + types: [published] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + release: + permissions: + id-token: write # Required for authentication using OIDC + runs-on: ubuntu-latest + steps: + - name: 📚 Checkout branch + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Set up the Dart SDK and provision the OIDC token used for publishing. + - name: đŸŽ¯ Setup Dart + uses: dart-lang/setup-dart@v1 + + - name: đŸĻ Install Flutter + uses: subosito/flutter-action@v2 + + - name: đŸ“Ļ Install Tools + run: flutter pub global activate melos + + - name: 🔧 Bootstrap Workspace + run: melos bootstrap --verbose + + - name: đŸŒĩ Dry Run + run: melos run lint:pub + + - name: 🚀 Release to pub.dev + run: melos run release:pub \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 6a1d189df..103b82f96 100644 --- a/melos.yaml +++ b/melos.yaml @@ -149,12 +149,8 @@ scripts: - Note: you can also rely on your IDEs Dart Analysis / Issues window. lint:pub: - run: | - melos exec -c 5 --no-private --ignore="*example*" -- \ - flutter pub publish --dry-run - description: | - Run `pub publish --dry-run` in all packages. - - Note: you can also rely on your IDEs Dart Analysis / Issues window. + run: melos exec -c 1 --no-published --no-private --order-dependents -- "flutter pub publish -n" + description: Dry run `pub publish` in all packages. generate:all: run: melos run generate:dart && melos run generate:flutter @@ -206,3 +202,7 @@ scripts: description: Removes all the ignored files from the coverage report. packageFilters: dirExists: coverage + + release:pub: + run: melos exec -c 1 --no-published --no-private --order-dependents -- "flutter pub publish -f" + description: Publish all packages to pub.dev.