|
| 1 | +# Automates Releasing a Beta Version on a Feature Branch |
| 2 | +# melos version ensemble [version] |
| 3 | +# git push --follow-tags origin [branch] |
| 4 | + |
| 5 | +name: Release Beta Version |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + branch: |
| 11 | + description: "Branch to release from (cannot be main/master)" |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + default: "feature/my-branch" |
| 15 | + version: |
| 16 | + description: "Beta version (must be X.Y.Z-beta.N format)" |
| 17 | + required: true |
| 18 | + type: string |
| 19 | + default: "1.2.47-beta.1" |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: melos-beta-release-${{ github.repository }}-${{ inputs.branch }} |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: write |
| 27 | + |
| 28 | +jobs: |
| 29 | + version-and-push: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Validate inputs |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | +
|
| 36 | + branch="${{ inputs.branch }}" |
| 37 | + version="${{ inputs.version }}" |
| 38 | +
|
| 39 | + # Block main/master branches |
| 40 | + if [[ "$branch" == "main" || "$branch" == "master" ]]; then |
| 41 | + echo "::error::Cannot release beta to main/master. Use 'Release Ensemble Version' workflow instead." |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +
|
| 45 | + # Validate beta version format |
| 46 | + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]]; then |
| 47 | + echo "::error::Version must be in format X.Y.Z-beta.N (e.g., 1.2.47-beta.1)" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | +
|
| 51 | + echo "Branch: $branch" |
| 52 | + echo "Version: $version" |
| 53 | +
|
| 54 | + - name: Check branch exists |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | +
|
| 58 | + branch="${{ inputs.branch }}" |
| 59 | +
|
| 60 | + if ! git ls-remote --heads "https://github.com/${{ github.repository }}.git" "$branch" | grep -q "$branch"; then |
| 61 | + echo "::error::Branch '$branch' does not exist on remote." |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | +
|
| 65 | + echo "Branch '$branch' exists." |
| 66 | +
|
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + ref: ${{ inputs.branch }} |
| 71 | + fetch-depth: 0 |
| 72 | + token: ${{ secrets.RELEASE_TOKEN }} |
| 73 | + |
| 74 | + - name: Configure Git |
| 75 | + run: | |
| 76 | + git config user.name "github-actions[bot]" |
| 77 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 78 | +
|
| 79 | + - name: Setup Flutter SDK |
| 80 | + uses: subosito/flutter-action@v2 |
| 81 | + with: |
| 82 | + flutter-version: "3.32.5" |
| 83 | + cache: true |
| 84 | + |
| 85 | + - name: Install Melos |
| 86 | + run: dart pub global activate melos |
| 87 | + |
| 88 | + - name: Bootstrap |
| 89 | + run: melos bootstrap |
| 90 | + |
| 91 | + - name: Version packages |
| 92 | + run: melos version ensemble "${{ inputs.version }}" --yes |
| 93 | + |
| 94 | + - name: Push to feature branch |
| 95 | + run: git push origin ${{ inputs.branch }} --follow-tags |
0 commit comments