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

Automate deployment of new versions #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

n-bernat
Copy link

@n-bernat n-bernat commented Feb 21, 2024

Summary of changes

pubspec.yaml

  • Bumped version constraints, so the package supports Dart 3
  • Replaced lint with the official flutter_lints package and fixed a config file for lints
  • Removed dependency on html

generate_fonts.dart

  • Fonts are now generated based on the info.json file
  • In the future, it would be probably preferable to replace it with a bash script because installing Dart to do such a simple thing is a waste of resources

lucide_icons.dart

  • It will be replaced with icons generated by generate.yaml workflow (n-bernat@36fad92)

generate.yaml

  • (The whole magic happens in this action)
  • It's run once a day and fetches the latest release from lucide-icons/lucide
  • If there was a release, it downloads an icon font with info.json and copies those files to assets
  • After that, it runs the generator and bumps the version to match the one from the main repository
  • At the end, it commits changes and creates a new tag
  • ⚠️ Keep in mind that this workflow requires a repository-scoped deploy key, because:

operations act by Github-actions bot cannot trigger a new workflow run
~ https://github.com/orgs/community/discussions/27028

publish.yaml

Pub.dev configuration

In https://pub.dev/packages/lucide_icons/admin someone with admin rights has to enable publishing from GitHub Actions
image


Example run: https://github.com/n-bernat/lucide-flutter/actions/runs/8088943739

Example changes: n-bernat@935fbf8

@n-bernat n-bernat mentioned this pull request Feb 21, 2024
Comment on lines +20 to +44
run: |
RELEASE=$(curl -s "https://api.github.com/repos/lucide-icons/lucide/releases/latest")
TAG=$(printf "%s" $RELEASE | jq -r .tag_name)
echo "TAG=$TAG" >> $GITHUB_ENV
echo "Latest release: $TAG"

if [ $(git tag -l "$TAG") ]; then
echo "No changes since the latest release - aborting."
echo "EXISTS=true" >> $GITHUB_ENV
exit 0
fi

URL=$(printf "%s" $RELEASE | jq -r '.assets[] | select(.name | startswith("lucide-font")) | .browser_download_url')

echo "Downloading $URL"
curl -vLJO -H 'Accept: application/octet-stream' $URL
unzip -o lucide-font-*.zip

echo "Updating assets"
mv lucide-font/info.json assets/info.json
mv lucide-font/lucide.ttf assets/lucide.ttf

echo "Removing leftovers"
rm -rf lucide-font
rm -f lucide-font-*.zip

Choose a reason for hiding this comment

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

prefer to keep such longer scripts in a separate executable file, and just call that file from the CI pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants