improved update-version #7
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 Dart Packages | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'wasm_ffi/CHANGELOG.md' | |
- 'universal_ffi/CHANGELOG.md' | |
jobs: | |
analyze-and-publish: | |
name: Analyze and Publish Dart Packages | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: | |
- wasm_ffi | |
- universal_ffi | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Dart | |
uses: dart-lang/setup-dart@v1 | |
with: | |
channel: stable | |
- name: Check if relevant CHANGELOG is updated | |
id: changes | |
run: | | |
if [[ ! $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep "^${{ matrix.package }}/CHANGELOG.md$") ]]; then | |
echo "skip=true" >> $GITHUB_ENV | |
fi | |
- name: Analyze ${{ matrix.package }} | |
if: env.skip != 'true' | |
run: | | |
cd ${{ matrix.package }} | |
dart pub get | |
dart analyze | |
dart test | |
- name: Publish ${{ matrix.package }} (if valid) | |
if: env.skip != 'true' | |
env: | |
PUB_TOKEN: ${{ secrets.PUB_TOKEN }} | |
run: | | |
cd ${{ matrix.package }} | |
# Validate the package | |
dart pub publish --dry-run | |
# Publish the package if validation succeeds | |
echo "Publishing ${{ matrix.package }} to pub.dev..." | |
# dart pub publish --force |