|
1 |
| -# Workflow for Managing Pub.dev Packages |
| 1 | +# pub.dev_package_workflow |
| 2 | + |
| 3 | +This repository provides a powerful and streamlined set of GitHub Actions workflows designed to automate the entire lifecycle of your Dart and Flutter packages—from version bumping and changelog generation to publishing on pub.dev and deploying examples to GitHub Pages. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 🚀 Core Features |
| 8 | + |
| 9 | +- **Automated Version Bumping:** Automatically update `CHANGELOG.md`, `README.md`, and other files when you're ready to release. |
| 10 | +- **Git Tagging:** Automatically create and push Git tags for new versions. |
| 11 | +- **Flexible Publishing Triggers:** Publish packages automatically via special commit messages or by creating a release in the GitHub UI. |
| 12 | +- **Example App Deployment:** An optional workflow to build and deploy a Flutter web example to GitHub Pages. |
2 | 13 |
|
3 | 14 | ## Workflows
|
4 | 15 |
|
5 |
| -**This repository contains GitHub Actions workflows that simplify the management of your pub.dev packages:** |
| 16 | +This project contains three key GitHub Actions workflows. |
| 17 | + |
| 18 | +### 1. `process-package.yml` |
| 19 | + |
| 20 | +This is the primary workflow for managing releases directly from your commit messages. It triggers on every push to your `main` branch. |
| 21 | + |
| 22 | +- **Standard Commits:** For any normal commit message, the workflow does nothing. |
| 23 | +- **Prepare a Release (`+`):** If your commit message starts with a single plus sign (e.g., `+Added new feature`), the workflow will: |
| 24 | + - Run `dart format` and `dart fix --apply`. |
| 25 | + - Update your `CHANGELOG.md` with the commit message. |
| 26 | + - Generate a standardized `README.md` from a central template. |
| 27 | + - Commit these automated changes with the message `ci: bump version to v[version]`. |
| 28 | + - Create and push a Git tag for the new version. |
| 29 | +- **Prepare and Publish (`++`):** If your commit message starts with two plus signs (e.g., `++Major performance improvements`), the workflow will do **everything above** and then automatically **publish the package to pub.dev** if properly configured. See https://dart.dev/tools/pub/automated-publishing. |
| 30 | + |
| 31 | +### 2. `publish.yml` |
| 32 | + |
| 33 | +This workflow provides a manual trigger for publishing. It activates **only** when you create a new release in the GitHub UI. This is perfect for when you want to review changes on the `main` branch before deciding to publish. |
6 | 34 |
|
7 |
| -- The `prepare.yaml` workflow triggers on every push to the main branch. It automatically updates the CHANGELOG.md, formats the Dart code, and applies Dart fixes with each push. |
8 |
| -- The `publish.yaml` workflow activates upon the creation of a new release, automatically handling the package's publication to pub.dev. |
| 35 | +### 3. `deploy-example.yml` (Optional) |
9 | 36 |
|
10 |
| -## Setup Instructions |
| 37 | +If your project contains a Flutter web example in a `hosted_example` directory, this workflow will automatically build it and deploy it to GitHub Pages on every push to the `main` branch. This is great for providing live demos of your package. |
11 | 38 |
|
12 |
| -**1. Navigate to your project:** |
| 39 | +--- |
| 40 | + |
| 41 | +## 🛠️ Setup Instructions |
| 42 | + |
| 43 | +Setting up these workflows in your own package repository is simple. |
| 44 | + |
| 45 | +**1. Navigate to Your Project's Root Directory** |
| 46 | + |
| 47 | +Open your terminal and `cd` into the root of your Dart or Flutter package. |
13 | 48 |
|
14 | 49 | ```zsh
|
15 |
| -cd your_project |
| 50 | +cd /path/to/your_project |
16 | 51 | ```
|
17 | 52 |
|
18 |
| -**2. Clone this repo into a `.github/` folder:** |
| 53 | +**2. Clone this Workflow Repository** |
| 54 | + |
| 55 | +Clone this repository directly into a `.github` folder. This will create `.github/workflows` and `.github/scripts` for you. |
19 | 56 |
|
20 | 57 | ```zsh
|
21 | 58 | git clone https://github.com/dev-cetera/pub.dev_package_workflow.git .github
|
22 | 59 | ```
|
23 | 60 |
|
24 |
| -**3. Remove the `/.git` folder to include it to your project:** |
| 61 | +**3. Remove the Nested `.git` Directory** |
25 | 62 |
|
26 |
| -_On macOS and Linux:_ |
| 63 | +To make these workflow files part of your own project's Git history, you must delete the nested `.git` directory that was just cloned. |
27 | 64 |
|
28 |
| -```zsh |
29 |
| -rm -rf .github/.git/ |
30 |
| -``` |
| 65 | +**4. Configure `pub.dev` for Automated Publishing** |
31 | 66 |
|
32 |
| -_On Windows:_ |
| 67 | +For the `publish.yml` workflow to work, you must authorize GitHub Actions on `pub.dev`. |
33 | 68 |
|
34 |
| -```cmd |
35 |
| -rmdir /s /q .github/.git/ |
36 |
| -``` |
| 69 | +- Go to your package's page on `pub.dev` and click the **Admin** tab. |
| 70 | +- Under **Automated publishing**, click **Enable publishing from GitHub Actions**. |
| 71 | +- Set the **Repository** to your `username/repository_name`. |
| 72 | +- Set the **Tag pattern** to `v{{version}}`. |
0 commit comments