-
Notifications
You must be signed in to change notification settings - Fork 5
/
action.yml
121 lines (121 loc) · 5.12 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Melos action
description: Setup Melos for you GitHub workflow
author: Lukas Klingsbo
branding:
icon: loader
color: purple
inputs:
melos-version:
description: 'The Melos version to make available on the path'
required: false
run-bootstrap:
description: 'Whether bootstrap should run or not (default: true)'
required: false
default: 'true'
bootstrap-no-example:
description: 'Whether to pass the --no-example flag to melos bootstrap, this helps avoid race conditions in flutter packages, where pub get can be executed on the example project before melos has had a chance to generate its pubspec_overrides.yaml (default: false)'
required: false
default: 'false'
enforce-lockfile:
description: 'Whether the versions in the lockfiles should be enforced (default: false)'
required: false
default: 'false'
run-versioning:
description: 'Whether packages should be versioned (default: false)'
required: false
default: 'false'
run-versioning-prerelease:
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
default: 'false'
tag:
description: 'Whether packages should be tagged and pushed to the repository (default: false)'
required: false
default: 'false'
publish:
description: 'Whether packages should be published to pub.dev (default: false)'
required: false
default: 'false'
create-pr:
description: 'Whether a PR should be created with the versioning changes (default: false)'
required: false
default: 'false'
git-email:
description: 'The email to use when committing changes'
required: false
default: 'github-actions[bot]@users.noreply.github.com'
git-name:
description: 'The name to use when committing changes'
required: false
default: 'github-actions[bot]'
runs:
using: composite
steps:
- name: 'Activate melos'
run: dart pub global activate melos ${{ inputs.melos-version }}
shell: bash
- name: 'Run melos bootstrap'
if: ${{ inputs.run-bootstrap == 'true' }}
run: dart pub global run melos bootstrap ${{ inputs.enforce-lockfile == 'true' && '--enforce-lockfile' || '' }} ${{ inputs.bootstrap-no-example == 'true' && '--no-example' || '' }}
shell: bash
- name: 'Add melos to PATH'
run: command -v melos || echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
shell: bash
- name: 'Set up git config for email and name'
if: ${{ inputs.publish == 'true' || inputs.run-versioning == 'true' || inputs.run-versioning-prerelease == 'true' }}
run: |
git config --global user.email "${{ inputs.git-email }}"
git config --global user.name "${{ inputs.git-name }}"
shell: bash
- name: 'Run melos version'
if: ${{ inputs.run-versioning == 'true' }}
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 ${{ (inputs.include-private == 'true' && '--all') || '' }}
shell: bash
- name: 'Run melos publish (dry run)'
if: ${{ inputs.publish-dry-run == 'true' }}
run: melos publish -y --dry-run
shell: bash
- name: 'Create Pull Request with changes'
if: ${{ inputs.create-pr == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
title: 'chore(release): Publish packages'
body: 'Prepared all packages to be released to pub.dev'
branch: release-${{github.run_id}}
- name: 'Create and push tags to the repository'
if: ${{ inputs.tag == 'true' }}
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 ${{ (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'
if: ${{ inputs.publish == 'true' }}
env:
GITHUBREF: ${{ github.ref }}
# Support semver, e.g.: "refs/tags/my_package-v1.2.3+alpha.1"
run: |
PACKAGE_NAME=$(sed -E 's/refs\/tags\/([a-z0-9_]+)-v([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/' <<< $GITHUBREF) && \
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "Package name: $PACKAGE_NAME"
shell: bash
- name: 'Installs the Dart SDK and sets up the pipeline for usage with pub.dev (this sets up OIDC)'
if: ${{ inputs.publish == 'true' }}
uses: dart-lang/setup-dart@v1
- name: 'Publish package related to tag to pub.dev'
if: ${{ inputs.publish == 'true' }}
run: melos publish -y --no-dry-run --scope=$PACKAGE_NAME
shell: bash