From fd68ffdb13e27ab74f3df6590cd8f78e94e3c650 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 14:28:11 -0600 Subject: [PATCH 1/6] fixed validation publish condition --- .github/workflows/checks.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 278167c..216b564 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -83,12 +83,18 @@ jobs: - id: analyze-pubspec working-directory: ${{ inputs.package-path }} run: | - echo "package_name=$(yq '.name' pubspec.yaml)" >> $GITHUB_OUTPUT - echo "package_version=$(yq '.version' pubspec.yaml)" >> $GITHUB_OUTPUT + PACKAGE_NAME=$(yq '.name' pubspec.yaml) + PACKAGE_VERSION=$(yq '.version' pubspec.yaml) + echo "release_ref=refs/head/release_$PACKAGE_NAME_$PACKAGE_VERSION" >> $GITHUB_ENV + + - name: Debug + run: | + echo "Current Ref: ${{ github.ref}}" + echo "Analyzed Release Ref: ${{ steps.analyze-pubspec.outputs.release_ref }}" - name: Validate Publish # Only validate the publish for release pull requests, as determined by the branch name - if: github.ref == format('refs/head/release_{0}_{1}', steps.analyze-pubspec.outputs.package_name, steps.analyze-pubspec.outputs.package_version) + if: github.ref == steps.analyze-pubspec.outputs.release_ref run: dart pub publish --dry-run analyze-additional-checks: From e6d45d2a99e50f59892b7cc78333643734e02181 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 14:30:15 -0600 Subject: [PATCH 2/6] use github output instead of env --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 216b564..7c9f6d0 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -85,7 +85,7 @@ jobs: run: | PACKAGE_NAME=$(yq '.name' pubspec.yaml) PACKAGE_VERSION=$(yq '.version' pubspec.yaml) - echo "release_ref=refs/head/release_$PACKAGE_NAME_$PACKAGE_VERSION" >> $GITHUB_ENV + echo "release_ref=refs/head/release_$PACKAGE_NAME_$PACKAGE_VERSION" >> $GITHUB_OUTPUT - name: Debug run: | From 86cd671d4e154216a39291f0fc79ecc2d1f1f5e9 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 14:31:14 -0600 Subject: [PATCH 3/6] use head_ref --- .github/workflows/checks.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 7c9f6d0..1dd5ddc 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -85,16 +85,17 @@ jobs: run: | PACKAGE_NAME=$(yq '.name' pubspec.yaml) PACKAGE_VERSION=$(yq '.version' pubspec.yaml) + echo "release_ref=refs/head/release_$PACKAGE_NAME_$PACKAGE_VERSION" >> $GITHUB_OUTPUT - name: Debug run: | - echo "Current Ref: ${{ github.ref}}" + echo "Current Ref: ${{ github.head_ref }}" echo "Analyzed Release Ref: ${{ steps.analyze-pubspec.outputs.release_ref }}" - name: Validate Publish # Only validate the publish for release pull requests, as determined by the branch name - if: github.ref == steps.analyze-pubspec.outputs.release_ref + if: github.head_ref == steps.analyze-pubspec.outputs.release_ref run: dart pub publish --dry-run analyze-additional-checks: From c19b77e93f7a4d3230c751af77ddee2eea1af240 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 14:35:07 -0600 Subject: [PATCH 4/6] updated validation check --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 1dd5ddc..6f83421 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -86,7 +86,7 @@ jobs: PACKAGE_NAME=$(yq '.name' pubspec.yaml) PACKAGE_VERSION=$(yq '.version' pubspec.yaml) - echo "release_ref=refs/head/release_$PACKAGE_NAME_$PACKAGE_VERSION" >> $GITHUB_OUTPUT + echo "release_ref=release_${PACKAGE_NAME}_${PACKAGE_VERSION}" >> $GITHUB_OUTPUT - name: Debug run: | From 183c4a035ae343d808b005df2be25aa1b1a1208c Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 15:13:51 -0600 Subject: [PATCH 5/6] updated check to work with both dart 2 and dart 3 --- .github/workflows/checks.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 6f83421..00b0881 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -78,6 +78,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 + id: setup-dart with: sdk: ${{ inputs.sdk }} - id: analyze-pubspec @@ -86,16 +87,28 @@ jobs: PACKAGE_NAME=$(yq '.name' pubspec.yaml) PACKAGE_VERSION=$(yq '.version' pubspec.yaml) + echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT echo "release_ref=release_${PACKAGE_NAME}_${PACKAGE_VERSION}" >> $GITHUB_OUTPUT + # Only validate the publish for release pull requests, as determined by the branch name - name: Debug run: | + echo "Dart Version: ${{ steps.setup-dart.outputs.dart-version }}" echo "Current Ref: ${{ github.head_ref }}" echo "Analyzed Release Ref: ${{ steps.analyze-pubspec.outputs.release_ref }}" - - name: Validate Publish - # Only validate the publish for release pull requests, as determined by the branch name - if: github.head_ref == steps.analyze-pubspec.outputs.release_ref + # dart v2's `dart pub publish --dry-run` runs `dart analyze --fatal-infos`. This was updated in dart3 + # (see: https://github.com/dart-lang/pub/pull/3877). Because "infos" are not a valid failure condition + # we need to emulate the behavior of `dart pub publish --dry-run` for dart v2. + - name: Validate Publish (dart v2) + if: startsWith(steps.setup-dart.outputs.dart-version, '2') && github.head_ref == steps.analyze-pubspec.outputs.release_ref + run: | + grep -q "## ${{ steps.analyze-pubspec.outputs.package_version }}" CHANGELOG.md || { + echo "::error::CHANGELOG.md does not contain a section for version $PACKAGE_VERSION" + exit 1 + } + - name: Validate Publish (dart v3) + if: startsWith(steps.setup-dart.outputs.dart-version, '3') && github.head_ref == steps.analyze-pubspec.outputs.release_ref run: dart pub publish --dry-run analyze-additional-checks: From 0b64204317167db66c9829e23af61a799687e757 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 6 Sep 2024 15:17:30 -0600 Subject: [PATCH 6/6] force publish only in dart 2 --- .github/workflows/publish.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 06ced7a..f59bb3e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -39,14 +39,19 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 + id: setup-dart with: sdk: ${{ inputs.sdk }} - name: Install dependencies run: dart pub get - - name: Publish - dry run - run: dart pub publish --dry-run + # For dart 2, we have to force publish because `analyze --fatal-infos` is ran. + # This was fixed in dart 3, so we don't need to force publish for this version + - name: Publish (dart 2) + if: startsWith(steps.setup-dart.outputs.dart-version, '2') + run: dart pub publish --force - - name: Publish - run: dart pub publish -f \ No newline at end of file + - name: Publish (dart 3) + if: startsWith(steps.setup-dart.outputs.dart-version, '3') + run: dart pub publish \ No newline at end of file