Skip to content

chore(dart): use melos to publish packages #1786

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

Merged
merged 2 commits into from
Jul 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ for package_dir in "${!packages[@]}"; do
echo "Creating new tag..."
git tag "$tag_prefix-$new_version"
git push origin "$tag_prefix-$new_version"
echo "$tag_prefix=true" >> "$GITHUB_OUTPUT"
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "Version was not updated in $package_dir."
fi
Expand Down
60 changes: 17 additions & 43 deletions clients/algoliasearch-client-dart/.github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,51 +41,25 @@ jobs:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}

outputs:
PUBLISH_CORE: ${{ steps.version.outputs.core }}
PUBLISH_SEARCH: ${{ steps.version.outputs.search }}
PUBLISH_INSIGHTS: ${{ steps.version.outputs.insights }}
PUBLISH_ALGOLIASEARCH: ${{ steps.version.outputs.algoliasearch }}
PUBLISH: ${{ steps.version.outputs.publish }}

publish_algoliasearch:
publish:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to merge all 3 jobs in the same one and just use more steps ? I feel like having a full job just to compute the version is a bit overkill, and because all jobs depends on each other it could work well in a single flow.
Anyway just rumbling it works fine like this !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is because the publish workflow uses a manual validation step

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh then that make sense

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've structured it this way to prevent the repository from making a publish commit when there is nothing to publish. If such a scenario is impossible, then we can certainly eliminate this logic!

needs: version
name: Publish AlgoliaSearch
if: ${{ needs.version.outputs.PUBLISH_ALGOLIASEARCH == 'true' }}
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
name: Publish
runs-on: ubuntu-20.04
if: ${{ needs.version.outputs.PUBLISH == 'true' }}
permissions:
id-token: write
with:
environment: 'pub.dev'
working-directory: packages/algoliasearch

publish_core:
needs: version
name: Publish Client Core
if: ${{ needs.version.outputs.PUBLISH_CORE == 'true' }}
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
permissions:
id-token: write
with:
environment: 'pub.dev'
working-directory: packages/client-core

publish_search:
needs: version
name: Publish Search Client
if: ${{ needs.version.outputs.PUBLISH_SEARCH == 'true' }}
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
permissions:
id-token: write
with:
environment: 'pub.dev'
working-directory: packages/client-search
environment: pub.dev
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1

publish_insights:
needs: version
name: Publish Insights Client
if: ${{ needs.version.outputs.PUBLISH_INSIGHTS == 'true' }}
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
permissions:
id-token: write
with:
environment: 'pub.dev'
working-directory: packages/client-insights
- name: Install Tools
run: dart pub global activate melos
- name: Bootstrap Workspace
run: melos bootstrap
- name: Install dependencies
run: melos get
- name: Publish packages
run: melos publish --no-dry-run --yes