Skip to content

Commit 977cd7b

Browse files
committed
✨ Add an action to resolve distro name for debian like distributions
Signed-off-by: kei-g <km.8k6ce+github@gmail.com>
1 parent a8a3103 commit 977cd7b

6 files changed

Lines changed: 123 additions & 0 deletions

File tree

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"reloadagent",
2121
"subkey",
2222
"tada",
23+
"trixie",
2324
"typeof"
2425
]
2526
}

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trim_trailing_whitespace = true
1515
[*.{json,md,ts,yml}]
1616
indent_size = 2
1717
indent_style = space
18+
tab_width = 2
1819

1920
[*.md]
2021
max_line_length = off

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ jobs:
55
steps:
66
- name: Checkout the repository with digest
77
uses: kei-g/github/checkout@main
8+
debian:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: kei-g/github/debian/resolve-distro@debian/resolve-distro
12+
with:
13+
codename: ${{ matrix.codename }}
14+
strategy:
15+
matrix:
16+
codename:
17+
- bookworm
18+
- bullseye
19+
- buster
20+
- focal
21+
- forky
22+
- groovy
23+
- hirsute
24+
- impish
25+
- jammy
26+
- jessie
27+
- kinetic
28+
- lunar
29+
- mantic
30+
- noble
31+
- oracular
32+
- plucky
33+
- questing
34+
- resolute
35+
- stretch
36+
- trixie
837
import-gpg:
938
name: Import GPG
1039
runs-on: ubuntu-latest

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
[`kei-g/github/create-release`][create-release-url] - Create a release on GitHub according to the tag in your repository
66

7+
[`kei-g/github/debian/resolve-distro`][debian-resolve-distro-url] - Resolve distro name and release version from codename for debian like distributions
8+
79
[`kei-g/github/import-gpg`][import-gpg-url] - Import a GPG key
810

911
[`kei-g/github/put-changes`][put-changes-url] - Put changes with a signature of the [`github-actions[bot]`][github-action-bot-url]
@@ -22,6 +24,7 @@ Contributions are welcome! See [Contributor's Guide](https://github.com/kei-g/gi
2224

2325
[checkout-url]:https://github.com/kei-g/github/tree/main/checkout
2426
[create-release-url]:https://github.com/kei-g/github/tree/main/create-release
27+
[debian-resolve-distro-url]:https://github.com/kei-g/github/tree/main/debian/resolve-distro
2528
[github-action-bot-url]:https://github.com/apps/github-actions
2629
[import-gpg-url]:https://github.com/kei-g/github/tree/main/import-gpg
2730
[license-url]:https://github.com/kei-g/github/blob/main/LICENSE

debian/resolve-distro/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Resolve distro name
2+
3+
This action resolves distro name and release version from codename for debian like distributions.
4+
5+
# Usage
6+
7+
```yaml
8+
- uses: kei-g/github/debian/resolve-distro@main
9+
with:
10+
# Release codename like noble, trixie, and so on.
11+
codename: noble
12+
# Trim version suffix, or not.
13+
trim-version-suffix: true
14+
```
15+
16+
# Action Outputs
17+
18+
| Output Name | Description |
19+
|-|-|
20+
| **long_name** | The long name of release version, like `debian-13` or `ubuntu-24.04`. |
21+
| **name** | The name of distribution, `debian` or `ubuntu`. |
22+
| **version** | The release version. |
23+
24+
# License
25+
26+
The scripts and documentation in this project are released under the [BSD-3-Clause License](https://github.com/kei-g/github/blob/main/LICENSE)
27+
28+
# Contributions
29+
30+
Contributions are welcome! See [Contributor's Guide](https://github.com/kei-g/github/blob/main/CONTRIBUTING.md)
31+
32+
# Code of Conduct
33+
34+
:clap: Be nice. See [our code of conduct](https://github.com/kei-g/github/blob/main/CODE_OF_CONDUCT.md)

debian/resolve-distro/action.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
author: 'kei-g'
2+
branding:
3+
color: orange
4+
icon: anchor
5+
description: >
6+
Resolve distro name and release version from codename for debian like distributions.
7+
inputs:
8+
codename:
9+
description: >
10+
Release codename like bookworm, noble, and so on.
11+
required: true
12+
trim-version-suffix:
13+
default: 'true'
14+
description: >
15+
Trim version suffix, or not.
16+
name: 'Resolve distro name'
17+
outputs:
18+
long-name:
19+
description: >
20+
Name with version.
21+
value: ${{ jobs.get.outputs.name }}-${{ jobs.get.outputs.version}}
22+
name:
23+
description: >
24+
debian or ubuntu.
25+
value: ${{ jobs.get.outputs.name }}
26+
version:
27+
description: >
28+
Release version number.
29+
value: ${{ jobs.get.outputs.version }}
30+
runs:
31+
steps:
32+
- id: get
33+
name: Get corresponding distro name and release version
34+
run: |
35+
matched=$(grep -PR ",${{ inputs.codename }}," /usr/share/distro-info)
36+
{
37+
echo ::group::matched
38+
echo $matched
39+
echo ::endgroup::
40+
} >&2
41+
{
42+
echo name=$(grep -P '(?<=\/)[^/.]+(?=\.)' -o <<< $matched)
43+
case '${{ inputs.trim-version-suffix }}' in
44+
true)
45+
echo version=$(grep -P '(?<=\.csv:)\d+(\.\d+)*' -o <<< $matched)
46+
;;
47+
*)
48+
echo version=$(grep -P '(?<=\.csv:)[^,]+' -o <<< $matched)
49+
;;
50+
esac
51+
} \
52+
| tee -a $GITHUB_OUTPUT \
53+
>&2
54+
shell: bash
55+
using: 'composite'

0 commit comments

Comments
 (0)