Skip to content

Commit

Permalink
feat: Allow versioning non-published packages (#20)
Browse files Browse the repository at this point in the history
This is needed, e.g. when app developers create a common package for
their needs, but isn't meant to be published to pub.dev.

Example workflow:
https://github.com/Oberhauser-Dev/wrestling_scoreboard/actions/runs/11755620616/job/32750863728#step:4:258
  • Loading branch information
Gustl22 authored Nov 9, 2024
1 parent be64ed7 commit 68b03fa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ steps:
There are a few parameters that can be set to customize the behavior of the
action, they are all optional.
| Parameter | Default | Description |
|---------------------------|-----------------------|-----------------------------------------------------------|
| melos-version | latest | The version of Melos to activate. |
| run-bootstrap | true | Whether to run `melos bootstrap` after activating Melos. |
| enforce-lockfile | false | Whether the versions in the lockfiles should be enforced. |
| run-versioning | false | Whether packages should be versioned. |
| run-versioning-prerelease | false | Whether packages should be versioned as a prerelease. |
| publish-dry-run | false | Whether packages should be dry-run published. |
| publish | false | Whether packages should be published to pub.dev. |
| create-pr | false | Whether to create a PR with the changes made by Melos. |
| tag | false | Whether tags for the packages should be created. |
| git-email | [email protected] | The email to use when committing changes. |
| git-name | Melos Action | The name to use when committing changes. |
| Parameter | Default | Description |
|---------------------------|-----------------------|------------------------------------------------------------------|
| melos-version | latest | The version of Melos to activate. |
| run-bootstrap | true | Whether to run `melos bootstrap` after activating Melos. |
| enforce-lockfile | false | Whether the versions in the lockfiles should be enforced. |
| run-versioning | false | Whether packages should be versioned. |
| run-versioning-prerelease | false | Whether packages should be versioned as a prerelease. |
| include-private | false | Whether to include or exclude packages with `publish_to: "none"` |
| publish-dry-run | false | Whether packages should be dry-run published. |
| publish | false | Whether packages should be published to pub.dev. |
| create-pr | false | Whether to create a PR with the changes made by Melos. |
| tag | false | Whether tags for the packages should be created. |
| git-email | [email protected] | The email to use when committing changes. |
| git-name | Melos Action | The name to use when committing changes. |
To set a specific parameter you use the `with` keyword in your action, like in
the example below.
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: 'Whether packages should be versioned as a prerelease (default: false)'
required: false
default: 'false'
include-private:
description: 'Whether to include or exclude packages with `publish_to: "none"` (default: false)'
required: false
default: 'false'
publish-dry-run:
description: 'Whether packages should be dry-run published (default: false)'
required: false
Expand Down Expand Up @@ -73,11 +77,11 @@ runs:
shell: bash
- name: 'Run melos version'
if: ${{ inputs.run-versioning == 'true' }}
run: melos version --yes --no-git-tag-version
run: melos version --yes --no-git-tag-version ${{ (inputs.include-private == 'true' && '--all') || '' }}
shell: bash
- name: 'Run melos version as a prerelease'
if: ${{ inputs.run-versioning-prerelease == 'true' }}
run: melos version --yes --no-git-tag-version --prerelease
run: melos version --yes --no-git-tag-version --prerelease ${{ (inputs.include-private == 'true' && '--all') || '' }}
shell: bash
- name: 'Run melos publish (dry run)'
if: ${{ inputs.publish-dry-run == 'true' }}
Expand All @@ -95,7 +99,7 @@ runs:
run: |
# We don't care about errors due to creating new tags (`|| true`)
# since for all packages that didn't get a new release, the tag already exists.
melos exec -c 1 --no-private -- git tag \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION || true
melos exec -c 1 ${{ (inputs.include-private == 'true' && '--private') || '--no-private' }} -- git tag \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION || true
git push --tags
shell: bash
- name: 'Extract tag info'
Expand Down
2 changes: 1 addition & 1 deletion examples/01-workflow-dispatch/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
tag: true
- run: |
melos exec -c1 --no-published --no-private --order-dependents -- \
melos exec -c 1 --no-published --no-private --order-dependents -- \
gh workflow run release-publish.yml \
--ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION
env:
Expand Down
2 changes: 1 addition & 1 deletion examples/02-release-on-pr/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
tag: true
- run: |
melos exec -c1 --no-published --no-private --order-dependents -- \
melos exec -c 1 --no-published --no-private --order-dependents -- \
gh workflow run release-publish.yml \
--ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION
env:
Expand Down

0 comments on commit 68b03fa

Please sign in to comment.