Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEDX-1599: fixed validation publish condition #25

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,37 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
id: setup-dart
with:
sdk: ${{ inputs.sdk }}
- 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)

- 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)
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 }}"

# 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:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- name: Publish (dart 3)
if: startsWith(steps.setup-dart.outputs.dart-version, '3')
run: dart pub publish