Publish to pub.dev #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to pub.dev | |
on: | |
workflow_dispatch: | |
inputs: | |
mix: | |
type: boolean | |
description: publish mix | |
default: false | |
mix_lint: | |
type: boolean | |
description: publish mix_lint | |
default: false | |
mix_annotations: | |
type: boolean | |
description: publish mix_annotations | |
default: false | |
mix_generator: | |
type: boolean | |
description: publish mix_generator | |
default: false | |
remix: | |
type: boolean | |
description: publish remix | |
default: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish-dry-run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout mix repo | |
uses: actions/checkout@v4 | |
- name: Install FVM | |
shell: bash | |
run: | | |
curl -fsSL https://fvm.app/install.sh | bash | |
fvm use ${{ inputs.flutter-version }} --force | |
- uses: kuhnroyal/flutter-fvm-config-action@v2 | |
id: fvm-config-action | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }} | |
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }} | |
- name: Setup Melos | |
uses: bluefireteam/melos-action@v3 | |
- name: Run melos fix | |
run: | | |
PACKAGES="" | |
if [[ "${{ github.event.inputs.mix_lint }}" == "false" ]]; then | |
PACKAGES+=" --ignore=packages/mix_lint" | |
fi | |
if [[ "${{ github.event.inputs.mix_annotations }}" == "false" ]]; then | |
PACKAGES+=" --ignore=packages/mix_annotations" | |
fi | |
if [[ "${{ github.event.inputs.mix_generator }}" == "false" ]]; then | |
PACKAGES+=" --ignore=packages/mix_generator" | |
fi | |
if [[ "${{ github.event.inputs.mix }}" == "false" ]]; then | |
PACKAGES+=" --ignore=packages/mix" | |
fi | |
if [[ "${{ github.event.inputs.remix }}" == "false" ]]; then | |
PACKAGES+=" --ignore=packages/remix" | |
fi | |
if [[ -n "$PACKAGES" ]]; then | |
echo "$PACKAGES" | |
melos publish --dry-run --yes --no-private "$PACKAGES" | |
else | |
echo "No packages selected for publishing" | |
fi | |
shell: bash | |
test-mincompat: | |
needs: [publish-dry-run] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout mix repo | |
uses: actions/checkout@v4 | |
- name: Run Tests | |
uses: ./.github/actions/test/ | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
flutter-version: 'mincompat' | |
test-stable: | |
needs: [publish-dry-run] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout mix repo | |
uses: actions/checkout@v4 | |
- name: Run Tests | |
uses: ./.github/actions/test/ | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
needs: [test-mincompat, test-stable, publish-dry-run] | |
environment: Production | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
package: [mix_lint, mix_annotations, mix_generator, mix, remix] | |
include: | |
- package: mix_lint | |
path: packages/mix_lint | |
condition: ${{ github.event.inputs.mix_lint == 'true' }} | |
- package: mix_annotations | |
path: packages/mix_annotations | |
condition: ${{ github.event.inputs.mix_annotations == 'true' }} | |
- package: mix_generator | |
path: packages/mix_generator | |
condition: ${{ github.event.inputs.mix_generator == 'true' }} | |
- package: mix | |
path: packages/mix | |
condition: ${{ github.event.inputs.mix == 'true' }} | |
- package: remix | |
path: packages/remix | |
condition: ${{ github.event.inputs.remix == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: '>> publish ${{ matrix.package }} package to pub.dev <<' | |
if: ${{ matrix.condition }} | |
id: publish | |
uses: k-paxian/dart-package-publisher@master | |
with: | |
accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }} | |
refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }} | |
relativePath: ${{ matrix.path }} | |
# - name: 'Commit release tag' | |
# if: steps.publish.outputs.success | |
# uses: hole19/git-tag-action@master | |
# env: | |
# TAG: ${{steps.publish.outputs.package}}-${{steps.publish.outputs.localVersion}} | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |