From 427be0e0b88f24908ac162832b02cec399796b20 Mon Sep 17 00:00:00 2001 From: td Date: Wed, 19 Jul 2023 18:25:30 +0530 Subject: [PATCH] chore: add pub release job --- .github/workflows/app.yml | 26 ++++++++++++++++++++++++-- .github/workflows/main.yml | 28 ++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml index 8d1817e5..288bfa84 100644 --- a/.github/workflows/app.yml +++ b/.github/workflows/app.yml @@ -36,6 +36,8 @@ jobs: scripts/prepare.sh scripts/test_driver.sh" +# coverage is done on the flutter image because we setup olm there +# coverage_without_olm is done on dart images because why not :D coverage: runs-on: ubuntu-latest container: @@ -44,7 +46,7 @@ jobs: - uses: actions/checkout@v3 - name: Run tests run: | - sed -i 's/#\([^ ]\)/\1/g' pubspec.yaml + sed -i 's/#flutter_test/flutter_test/g' pubspec.yaml rm -r example ./scripts/prepare.sh ./scripts/test.sh @@ -70,7 +72,27 @@ jobs: image: dart:${{inputs.dart_version}} steps: - uses: actions/checkout@v3 - - name: Run tests + - name: pub.dev publish dry run run: | dart pub get dart pub publish --dry-run + + pub-dev: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + container: + image: dart:${{inputs.dart_version}} + steps: + - uses: actions/checkout@v3 + - name: pub.dev publish + run: | + if [ -z ${{ secrets.PUB_DEV_CREDENTIALS }}" ]; then + echo "Missing PUB_DEV_CREDENTIALS environment variable" + exit 1 + fi + + mkdir -p ~/.config/dart/ + cp "${{ secrets.PUB_DEV_CREDENTIALS }}" ~/.config/dart/pub-credentials.json + + dart pub get + dart pub publish --force diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 173a43cf..7f4e5780 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - v[0-9]+.[0-9]+.[0-9]+ pull_request: merge_group: @@ -11,14 +13,31 @@ concurrency: group: ${{ github.ref }} cancel-in-progress: true +env: + FLUTTER_VERSION: 3.10.6 + DART_VERSION: 3.0.6 + jobs: + # because there is no easy way to pass env variables to jobs + versions: + runs-on: ubuntu-latest + outputs: + flutter_version: ${{ steps.flutterver.outputs.FLUTTER_VERSION }} + dart_version: ${{ steps.dartver.outputs.DART_VERSION }} + steps: + - id: flutterver + run: echo "FLUTTER_VERSION=${{ env.FLUTTER_VERSION }}" >> "$GITHUB_OUTPUT" + - id: dartver + run: echo "DART_VERSION=${{ env.DART_VERSION }}" >> "$GITHUB_OUTPUT" + dart: permissions: contents: read uses: famedly/frontend-ci-templates/.github/workflows/dart.yml@main + needs: [versions] with: - flutter_version: 3.10.4 - dart_version: 3.0.0 + flutter_version: ${{ needs.versions.outputs.flutter_version }} + dart_version: ${{ needs.versions.outputs.dart_version }} secrets: ssh_key: "${{ secrets.CI_SSH_PRIVATE_KEY }}" @@ -30,6 +49,7 @@ jobs: app_jobs: secrets: inherit uses: ./.github/workflows/app.yml + needs: [versions] with: - flutter_version: 3.10.4 - dart_version: 3.0.3 + flutter_version: ${{ needs.versions.outputs.flutter_version }} + dart_version: ${{ needs.versions.outputs.dart_version }}