@liblaf/actions 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,107 @@
1
+ name: Authenticate
2
+
3
+ author: liblaf
4
+
5
+ description: Authenticate
6
+
7
+ inputs:
8
+ app-id:
9
+ description: GitHub App ID
10
+ required: false
11
+ private-key:
12
+ description: GitHub App private key
13
+ required: false
14
+ owner:
15
+ description: The owner of the GitHub App installation (defaults to current repository owner)
16
+ required: false
17
+ repositories:
18
+ description: Comma or newline-separated list of repositories to install the GitHub App on (defaults to current repository if owner is unset)
19
+ required: false
20
+ skip-token-revoke:
21
+ description: If true, the token will not be revoked when the current job is complete
22
+ required: false
23
+ default: "false"
24
+
25
+ outputs:
26
+ author:
27
+ description: author
28
+ value: ${{ steps.author.outputs.author }}
29
+ author-name:
30
+ description: author-name
31
+ value: ${{ steps.author.outputs.author-name }}
32
+ author-email:
33
+ description: author-email
34
+ value: ${{ steps.author.outputs.author-email }}
35
+ committer:
36
+ description: committer
37
+ value: ${{ steps.committer.outputs.committer }}
38
+ committer-name:
39
+ description: committer-name
40
+ value: ${{ steps.committer.outputs.committer-name }}
41
+ committer-email:
42
+ description: committer-email
43
+ value: ${{ steps.committer.outputs.committer-email }}
44
+ token:
45
+ description: GitHub installation access token
46
+ value: ${{ steps.app.outputs.token || github.token }}
47
+
48
+ runs:
49
+ using: composite
50
+ steps:
51
+ - name: Create GitHub App Token
52
+ id: app
53
+ uses: actions/create-github-app-token@v2
54
+ with:
55
+ app-id: ${{ inputs.app-id }}
56
+ private-key: ${{ inputs.private-key }}
57
+ owner: ${{ inputs.owner }}
58
+ repositories: ${{ inputs.repositories }}
59
+ skip-token-revoke: ${{ inputs.skip-token-revoke }}
60
+ continue-on-error: true
61
+ - id: author
62
+ name: Config Git Author
63
+ run: |-
64
+ GIT_AUTHOR_NAME='${{ github.actor }}'
65
+ GIT_AUTHOR_EMAIL='${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com'
66
+ GIT_AUTHOR="${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>"
67
+ {
68
+ printf 'GIT_AUTHOR_NAME=%s\n' "$GIT_AUTHOR_NAME"
69
+ printf 'GIT_AUTHOR_EMAIL=%s\n' "$GIT_AUTHOR_EMAIL"
70
+ printf 'GIT_AUTHOR=%s\n' "$GIT_AUTHOR"
71
+ } >> "$GITHUB_ENV"
72
+ {
73
+ printf 'author-name=%s\n' "$GIT_AUTHOR_NAME"
74
+ printf 'author-email=%s\n' "$GIT_AUTHOR_EMAIL"
75
+ printf 'author=%s\n' "$GIT_AUTHOR"
76
+ } >> "$GITHUB_OUTPUT"
77
+ shell: bash
78
+ - id: committer
79
+ name: Config Git Committer
80
+ run: |-
81
+ if [[ '${{ steps.app.outcome }}' == 'success' ]]; then
82
+ app_slug='${{ steps.app.outputs.app-slug }}'
83
+ else
84
+ app_slug='github-actions'
85
+ fi
86
+ GIT_COMMITTER_NAME="${app_slug}[bot]"
87
+ id="$(gh api "/users/$GIT_COMMITTER_NAME" --jq '.id')"
88
+ GIT_COMMITTER_EMAIL="$id+$GIT_COMMITTER_NAME@users.noreply.github.com"
89
+ GIT_COMMITTER="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
90
+ {
91
+ printf 'GIT_COMMITTER_NAME=%s\n' "$GIT_COMMITTER_NAME"
92
+ printf 'GIT_COMMITTER_EMAIL=%s\n' "$GIT_COMMITTER_EMAIL"
93
+ printf 'GIT_COMMITTER=%s\n' "$GIT_COMMITTER"
94
+ } >> "$GITHUB_ENV"
95
+ {
96
+ printf 'committer-name=%s\n' "$GIT_COMMITTER_NAME"
97
+ printf 'committer-email=%s\n' "$GIT_COMMITTER_EMAIL"
98
+ printf 'committer=%s\n' "$GIT_COMMITTER"
99
+ } >> "$GITHUB_OUTPUT"
100
+ shell: bash
101
+ env:
102
+ GH_TOKEN: ${{ steps.app.outputs.token || github.token }}
103
+ - name: Config Git
104
+ run: |-
105
+ git config --global user.name '${{ steps.committer.outputs.committer-name }}'
106
+ git config --global user.email '${{ steps.committer.outputs.committer-email }}'
107
+ shell: bash
@@ -0,0 +1,109 @@
1
+ # yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2
+
3
+ name: Authenticate GitHub App
4
+
5
+ author: liblaf
6
+
7
+ description: TODO
8
+
9
+ inputs:
10
+ app-id:
11
+ description: GitHub App ID
12
+ required: false
13
+ private-key:
14
+ description: GitHub App private key
15
+ required: false
16
+ owner:
17
+ description: The owner of the GitHub App installation (defaults to current repository owner)
18
+ required: false
19
+ repositories:
20
+ description: Comma or newline-separated list of repositories to install the GitHub App on (defaults to current repository if owner is unset)
21
+ required: false
22
+ skip-token-revoke:
23
+ description: If true, the token will not be revoked when the current job is complete
24
+ required: false
25
+ default: "false"
26
+
27
+ outputs:
28
+ author:
29
+ description: author
30
+ value: ${{ steps.author.outputs.author }}
31
+ author-name:
32
+ description: author-name
33
+ value: ${{ steps.author.outputs.author-name }}
34
+ author-email:
35
+ description: author-email
36
+ value: ${{ steps.author.outputs.author-email }}
37
+ committer:
38
+ description: committer
39
+ value: ${{ steps.committer.outputs.committer }}
40
+ committer-name:
41
+ description: committer-name
42
+ value: ${{ steps.committer.outputs.committer-name }}
43
+ committer-email:
44
+ description: committer-email
45
+ value: ${{ steps.committer.outputs.committer-email }}
46
+ token:
47
+ description: GitHub installation access token
48
+ value: ${{ steps.app.outputs.token || github.token }}
49
+
50
+ runs:
51
+ using: composite
52
+ steps:
53
+ - name: Create GitHub App Token
54
+ id: app
55
+ uses: actions/create-github-app-token@v2
56
+ with:
57
+ app-id: ${{ inputs.app-id }}
58
+ private-key: ${{ inputs.private-key }}
59
+ owner: ${{ inputs.owner }}
60
+ repositories: ${{ inputs.repositories }}
61
+ skip-token-revoke: ${{ inputs.skip-token-revoke }}
62
+ continue-on-error: true
63
+ - id: author
64
+ name: Config Git Author
65
+ run: |-
66
+ GIT_AUTHOR_NAME='${{ github.actor }}'
67
+ GIT_AUTHOR_EMAIL='${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com'
68
+ GIT_AUTHOR="${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>"
69
+ {
70
+ printf 'GIT_AUTHOR_NAME=%s\n' "$GIT_AUTHOR_NAME"
71
+ printf 'GIT_AUTHOR_EMAIL=%s\n' "$GIT_AUTHOR_EMAIL"
72
+ printf 'GIT_AUTHOR=%s\n' "$GIT_AUTHOR"
73
+ } >> "$GITHUB_ENV"
74
+ {
75
+ printf 'author-name=%s\n' "$GIT_AUTHOR_NAME"
76
+ printf 'author-email=%s\n' "$GIT_AUTHOR_EMAIL"
77
+ printf 'author=%s\n' "$GIT_AUTHOR"
78
+ } >> "$GITHUB_OUTPUT"
79
+ shell: bash
80
+ - id: committer
81
+ name: Config Git Committer
82
+ run: |-
83
+ if [[ '${{ steps.app.outcome }}' == 'success' ]]; then
84
+ app_slug='${{ steps.app.outputs.app-slug }}'
85
+ else
86
+ app_slug='github-actions'
87
+ fi
88
+ GIT_COMMITTER_NAME="${app_slug}[bot]"
89
+ id="$(gh api "/users/$GIT_COMMITTER_NAME" --jq '.id')"
90
+ GIT_COMMITTER_EMAIL="$id+$GIT_COMMITTER_NAME@users.noreply.github.com"
91
+ GIT_COMMITTER="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
92
+ {
93
+ printf 'GIT_COMMITTER_NAME=%s\n' "$GIT_COMMITTER_NAME"
94
+ printf 'GIT_COMMITTER_EMAIL=%s\n' "$GIT_COMMITTER_EMAIL"
95
+ printf 'GIT_COMMITTER=%s\n' "$GIT_COMMITTER"
96
+ } >> "$GITHUB_ENV"
97
+ {
98
+ printf 'committer-name=%s\n' "$GIT_COMMITTER_NAME"
99
+ printf 'committer-email=%s\n' "$GIT_COMMITTER_EMAIL"
100
+ printf 'committer=%s\n' "$GIT_COMMITTER"
101
+ } >> "$GITHUB_OUTPUT"
102
+ shell: bash
103
+ env:
104
+ GH_TOKEN: ${{ steps.app.outputs.token || github.token }}
105
+ - name: Config Git
106
+ run: |-
107
+ git config --global user.name '${{ steps.committer.outputs.committer-name }}'
108
+ git config --global user.email '${{ steps.committer.outputs.committer-email }}'
109
+ shell: bash
@@ -0,0 +1,84 @@
1
+ # yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2
+
3
+ name: Changelog
4
+
5
+ author: liblaf
6
+
7
+ description: Changelog
8
+
9
+ inputs:
10
+ output:
11
+ description: Output file.
12
+ required: false
13
+ default: ${{ runner.temp }}/CHANGELOG.md
14
+ repository:
15
+ description: The owner and repository name. For example, `octocat/Hello-World`.
16
+ required: false
17
+ default: ${{ github.repository }}
18
+
19
+ # orhun/git-cliff-action
20
+ config:
21
+ description: config file location
22
+ required: false
23
+ args:
24
+ description: git-cliff arguments
25
+ required: false
26
+ default: --verbose
27
+ token:
28
+ description: GitHub API token
29
+ required: false
30
+ default: ${{ github.token }}
31
+
32
+ outputs:
33
+ changelog:
34
+ description: Output file that contains the generated changelog.
35
+ value: ${{ steps.cliff.outputs.changelog }}
36
+ content:
37
+ description: Content of the changelog.
38
+ value: ${{ steps.output.outputs.content }}
39
+ version:
40
+ description: Version of the latest release.
41
+ value: ${{ steps.cliff.outputs.version }}
42
+
43
+ runs:
44
+ using: composite
45
+ steps:
46
+ - id: config
47
+ name: Find Config
48
+ run: |-
49
+ if [[ -f '${{ inputs.config }}' ]]; then
50
+ printf 'config=%s\n' '${{ inputs.config }}' >> "$GITHUB_OUTPUT"
51
+ else
52
+ printf 'config=%s\n' '${{ github.action_path }}/cliff.toml' >> "$GITHUB_OUTPUT"
53
+ fi
54
+ shell: bash
55
+ - id: cliff
56
+ name: Generate Changelog
57
+ uses: orhun/git-cliff-action@v4
58
+ with:
59
+ config: ${{ steps.config.outputs.config }}
60
+ args: ${{ inputs.args }}
61
+ github_token: ${{ inputs.token }}
62
+ env:
63
+ GITHUB_REPO: ${{ inputs.repository }}
64
+ GITHUB_TOKEN: ${{ inputs.token }}
65
+ OUTPUT: ${{ inputs.output }}
66
+ - name: Ensure Output File Exists
67
+ run: |-
68
+ if [[ ! -f '${{ inputs.output }}' ]]; then
69
+ touch '${{ inputs.output }}'
70
+ fi
71
+ shell: bash
72
+ - name: Prettier
73
+ run: npx prettier --write '${{ inputs.output }}'
74
+ shell: bash
75
+ - id: output
76
+ name: Set Output
77
+ run: |-
78
+ delimiter="$(openssl rand -hex 8)"
79
+ {
80
+ printf 'content<<%s\n' "$delimiter"
81
+ cat '${{ inputs.output }}'
82
+ printf '%s\n' "$delimiter"
83
+ } >> "$GITHUB_OUTPUT"
84
+ shell: bash
@@ -0,0 +1,107 @@
1
+ [bump] # https://git-cliff.org/docs/configuration/bump
2
+ features_always_bump_minor = false
3
+ breaking_always_bump_major = false
4
+ initial_tag = "0.0.0"
5
+
6
+ [changelog] # https://git-cliff.org/docs/configuration/changelog
7
+ header = """# Changelog"""
8
+ # https://github.com/orhun/git-cliff/blob/main/cliff.toml
9
+ body = """
10
+ {%- macro remote_url() -%}
11
+ https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
12
+ {%- endmacro -%}
13
+
14
+ {%- macro print_commit(commit) -%}
15
+ - {% if commit.scope -%}**{{ commit.scope }}:** {% endif -%}\
16
+ {{ commit.message }} - \
17
+ ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))
18
+ {%- endmacro -%}
19
+
20
+ {%- macro user(username) -%}
21
+ {%- if username is ending_with("[bot]") -%}
22
+ {%- set botname = username | trim_end_matches(pat="[bot]") -%}
23
+ [@{{ username }}](https://github.com/apps/{{ botname }})
24
+ {%- else -%}
25
+ [@{{ username }}](https://github.com/{{ username }})
26
+ {%- endif -%}
27
+ {%- endmacro user -%}
28
+
29
+ {%- if version -%}
30
+ {%- if previous.version -%}
31
+ ## [{{ version | trim_start_matches(pat="v") }}]\
32
+ ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
33
+ {%- else -%}
34
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
35
+ {%- endif -%}
36
+ {%- else -%}
37
+ ## [unreleased]
38
+ {%- endif %}
39
+
40
+ {% for group, commits in commits | group_by(attribute="group") -%}
41
+ ### {{ group | striptags | trim | upper_first }}
42
+ {% for commit in commits | filter(attribute="scope") | sort(attribute="scope") -%}
43
+ {{ self::print_commit(commit=commit) }}
44
+ {% endfor -%}
45
+ {% for commit in commits -%}
46
+ {%- if not commit.scope -%}
47
+ {{ self::print_commit(commit=commit) }}
48
+ {% endif -%}
49
+ {%- endfor -%}
50
+ {%- endfor -%}
51
+
52
+ {%- if github -%}
53
+ {%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 -%}
54
+ ### ❤️ New Contributors
55
+ {% endif -%}
56
+ {%- for contributor in github.contributors | filter(attribute="is_first_time", value=true) -%}
57
+ - {{ self::user(username=contributor.username) }} made their first contribution
58
+ {%- if contributor.pr_number %} in \
59
+ [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }})
60
+ {%- endif %}
61
+ {% endfor -%}
62
+ {%- endif -%}
63
+ """
64
+ footer = ""
65
+ trim = true
66
+ render_always = false
67
+ postprocessors = []
68
+ output = "CHANGELOG.md"
69
+
70
+ [git] # https://git-cliff.org/docs/configuration/git
71
+ conventional_commits = true
72
+ filter_unconventional = false
73
+ split_commits = false
74
+ commit_preprocessors = [
75
+ # https://git-cliff.org/docs/tips-and-tricks#remove-gitmoji
76
+ # Remove gitmoji, both actual UTF emoji and :emoji:
77
+ { pattern = ' *(:\w+:|[\p{Emoji_Presentation}\p{Extended_Pictographic}](?:\u{FE0F})?\u{200D}?) *', replace = "" },
78
+ ]
79
+ commit_parsers = [
80
+ # https://github.com/arvinxx/gitmoji-commit-workflow/blob/8f21e287ec3c3f5144f3a606a3c737bea6d67e80/packages/changelog/src/transformer/typeDisplayName.ts
81
+ # https://github.com/conventional-changelog/conventional-changelog/blob/65550d9a30cfab4b00b3e982e42bd68fedafcefc/packages/conventional-changelog-conventionalcommits/src/constants.js
82
+ # https://github.com/lobehub/lobe-cli-toolbox/blob/09ce889f879850d8bc081da5df420c87b99379ac/packages/lobe-commit/src/constants/gitmojis.ts
83
+ { message = '^(?<type>\w+)(\((?<scope>\w+)\))?(?<breaking>!):', group = "<!-- 00 -->💥 BREAKING CHANGES" },
84
+ { message = "BREAKING CHANGE", group = "<!-- 00 -->💥 BREAKING CHANGES" },
85
+ { message = "^chore", group = "🎫 Chores", skip = true },
86
+ { message = "pre-commit autoupdate", skip = true },
87
+ { message = "sync with (repo|repository) template", skip = true },
88
+ { message = "sync with template (repo|repository)", skip = true },
89
+ { message = "update pre-commit hooks", skip = true },
90
+ { message = '^fix\((?<scope>deps(-dev)?)\):', group = "<!-- 25 -->⬆️ Dependencies" },
91
+ { message = "^feat", group = "<!-- 10 -->✨ Features" },
92
+ { message = "^fix", group = "<!-- 20 -->🐛 Bug Fixes" },
93
+ { message = "^perf", group = "<!-- 30 -->⚡ Performance Improvements" },
94
+ { message = "^revert", group = "<!-- 40 -->⏪ Reverts" },
95
+ { message = "^docs", group = "<!-- 50 -->📝 Documentation" },
96
+ { message = "^style", group = "<!-- 60 -->💄 Styles" },
97
+ { message = "^refactor", group = "<!-- 70 -->♻ Code Refactoring" },
98
+ { message = "^test", group = "<!-- 80 -->✅ Tests" },
99
+ { message = "^build", group = "<!-- 90 -->👷 Build System" },
100
+ { message = "^ci", group = "<!-- 95 -->🔧 Continuous Integration" },
101
+ ]
102
+ protect_breaking_commits = true
103
+ filter_commits = false
104
+ tag_pattern = "v[0-9].*"
105
+ ignore_tags = "latest"
106
+ topo_order = true
107
+ sort_commits = "newest"
@@ -0,0 +1,58 @@
1
+ # yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2
+
3
+ name: Commit
4
+
5
+ author: liblaf
6
+
7
+ description: Commit
8
+
9
+ inputs:
10
+ add-options:
11
+ description: Add options (eg. --update)
12
+ required: false
13
+ default: --verbose --update
14
+ fail-on-no-changes:
15
+ description: Whether or not to set action failure if there are no changes to commit
16
+ required: false
17
+ default: "false"
18
+ force:
19
+ description: Whether to force the update or to make sure the update is a fast-forward update when updating an existing ref
20
+ required: false
21
+ default: "false"
22
+ message:
23
+ description: The commit message
24
+ required: true
25
+ owner:
26
+ description: The owner of the GitHub repo, defaults to the owner of the repository this action is running in
27
+ required: false
28
+ ref:
29
+ description: Git reference to associate the commit with (e.g. `main`). If it does not exist it will be created. Defaults to the the current checkout ref.
30
+ required: false
31
+ repository:
32
+ description: The GitHub repository to commit to, defaults to the repository this action is running in
33
+ required: false
34
+ token:
35
+ description: The GitHub app installation token
36
+ required: false
37
+ default: ${{ github.token }}
38
+ working-directory:
39
+ description: The working directory, defaults to the current working directory
40
+ required: false
41
+
42
+ runs:
43
+ using: composite
44
+ steps:
45
+ - name: Git Add
46
+ run: git add ${{ inputs.add-options }}
47
+ shell: bash
48
+ - name: Commit
49
+ uses: dsanders11/github-app-commit-action@v1
50
+ with:
51
+ fail-on-no-changes: ${{ inputs.fail-on-no-changes }}
52
+ force: ${{ inputs.force }}
53
+ message: ${{ inputs.message }}
54
+ owner: ${{ inputs.owner }}
55
+ ref: ${{ inputs.ref }}
56
+ repository: ${{ inputs.repository }}
57
+ token: ${{ inputs.token }}
58
+ working-directory: ${{ inputs.working-directory }}
@@ -0,0 +1,25 @@
1
+ # yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2
+
3
+ name: Copier Update
4
+
5
+ author: liblaf
6
+
7
+ description: Copier update
8
+
9
+ runs:
10
+ using: composite
11
+ steps:
12
+ - name: Copier Update
13
+ run: |-
14
+ copier=(pipx run --pip-args cookiecutter copier)
15
+ if [[ -d '.config/copier/' ]]; then
16
+ find '.config/copier/' -iname '.copier-answers*' -type f -print0 |
17
+ while IFS= read -r -d '' answers_file; do
18
+ echo "::group::$answers_file"
19
+ "${copier[@]}" recopy --trust --answers-file "$answers_file" --force
20
+ echo "::endgroup::"
21
+ done
22
+ fi
23
+ shell: bash
24
+ env:
25
+ FORCE_COLOR: 1
@@ -0,0 +1,23 @@
1
+ name: Delete Cancelled Runs
2
+
3
+ author: liblaf
4
+
5
+ description: Deletes cancelled runs for a given workflow
6
+
7
+ inputs:
8
+ max-deletions:
9
+ description: The maximum number of cancelled runs to delete
10
+ default: "3"
11
+ repository:
12
+ description: The owner and repository name. For example, `octocat/Hello-World`.
13
+ default: ${{ github.repository }}
14
+ token:
15
+ description: GitHub access token
16
+ default: ${{ github.token }}
17
+ workflow:
18
+ description: The ID of the workflow. You can also pass the workflow file name as a string.
19
+ default: ${{ github.workflow_ref }}
20
+
21
+ runs:
22
+ using: node24
23
+ main: src/index.js