Skip to content

Commit 6b00166

Browse files
Gmin2asyncapi-bot
andauthored
feat: asyncapi release for alpine distros (#1834)
Co-authored-by: utnim2 <mintugogoi567@gmail.com> Co-authored-by: asyncapi-bot <info@asyncapi.io>
1 parent 1402922 commit 6b00166

File tree

5 files changed

+80
-11
lines changed

5 files changed

+80
-11
lines changed

.changeset/1834.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@asyncapi/cli': minor
3+
---
4+
5+
feat: asyncapi release for alpine distros
6+
7+
- 54ba750: feat: asyncapi on alpine distros
8+
- 44d72c3: fix: rename the scripts to use rename instead of tarballs
9+
10+

.github/workflows/upload-release-assets.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ jobs:
2121
npm_script: pack:tarballs
2222
dist_folder: tar
2323
extension: tar.gz
24+
- os: ubuntu-latest
25+
npm_script: pack:tarballs:alpine
26+
dist_folder: tar
27+
extension: alpine.tar.gz
28+
container: 'node:20-alpine'
29+
alpine: true
2430
- os: ubuntu-latest
2531
npm_script: pack:windows
2632
dist_folder: win32
@@ -37,21 +43,34 @@ jobs:
3743
npm_script: pack:macos
3844
dist_folder: macos
3945
extension: x64.pkg
46+
47+
container: ${{ matrix.container }}
48+
4049
steps:
4150
- name: Checkout repository
4251
uses: actions/checkout@v4
52+
4353
- name: Check package-lock version
4454
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
4555
id: lockversion
56+
4657
- name: Setup Node.js
58+
if: matrix.container == ''
4759
uses: actions/setup-node@v4
4860
with:
4961
node-version: "${{ steps.lockversion.outputs.version }}"
62+
63+
- name: Install dependencies in Alpine
64+
if: matrix.container == 'node:20-alpine'
65+
run: |
66+
apk add --no-cache git python3 make g++
67+
5068
- if: matrix.npm_script == 'pack:windows'
5169
name: install nodejs for windows
5270
uses: actions/setup-node@v4
5371
with:
5472
node-version: 20
73+
5574
- name: Get version from package.json
5675
uses: actions/github-script@v6
5776
id: extractver
@@ -77,7 +96,14 @@ jobs:
7796
run: npm run prepublishOnly
7897
- name: Assets generation
7998
shell: bash
80-
run: npm run ${{ matrix.npm_script }}
99+
run: |
100+
npm run ${{ matrix.npm_script }}
101+
if [[ "${{ matrix.alpine }}" == "true" ]]; then
102+
npm run pack:rename alpine
103+
else
104+
npm run pack:rename
105+
fi
106+
81107
- name: Update release
82108
uses: softprops/action-gh-release@v1
83109
with:
@@ -92,4 +118,4 @@ jobs:
92118
fields: repo,action,workflow
93119
text: 'AsyncAPI CLI release build artifacts failed'
94120
env:
95-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
121+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}

docs/installation.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,27 @@ curl -OL https://github.com/asyncapi/cli/releases/download/<replace this with th
162162
```
163163

164164
### Other distros
165-
You can install the AsyncAPI CLI for other Linux distros using the archive `tar.gz` file. To download the latest release of the CLI, run this command in your terminal:
165+
You can install the AsyncAPI CLI for other Linux distros using the archive `tar.gz` file.
166+
167+
#### For Alpine Linux / musl-based systems:
168+
To download the latest Alpine-compatible release, run this command in your terminal:
169+
```sh
170+
curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi-alpine.tar.gz
171+
```
172+
173+
To download a specific Alpine-compatible release, run this command in your terminal:
174+
```sh
175+
curl -OL https://github.com/asyncapi/cli/releases/download/<replace this with the specific CLI version e.g v0.13.0>/asyncapi-alpine.tar.gz
176+
```
177+
178+
Once downloaded, untar the file:
179+
```sh
180+
tar -xzf asyncapi-alpine.tar.gz
181+
```
182+
183+
#### For other Linux distributions (glibc-based):
184+
185+
To download the latest release of the CLI, run this command in your terminal:
166186
```sh
167187
curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.tar.gz
168188
```
@@ -177,6 +197,8 @@ Once you have downloaded the archived file, untar it by running this command in
177197
tar -xzf asyncapi.tar.gz
178198
```
179199

200+
### Setting up the symlink (for both Alpine and glibc versions):
201+
180202
The step above will create an `AsyncAPI` directory in the current path. To run the CLI from anywhere, you must create a `symlink`. If the current path you are on is `/user/local/bin`, for example, you must create the `symlink` in the `/user/local/bin` directory by following these steps:
181203
```sh
182204
# cd into the unarchived directory
@@ -191,3 +213,5 @@ ln -s <absolute-path>/bin/asyncapi /user/local/bin/asyncapi
191213
# The "asyncapi" command should be available to be used
192214
asyncapi
193215
```
216+
> [!NOTE]
217+
> If youare using Alpine Linux or any musl-based distribution, make sure to download the `-alpine.tar.gz` version to avoid glibc compatibility issues. The regular `asyncapi.tar.gz` file is compiled for glibc-based systems and will not work on Alpine.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"pack:macos": "oclif pack macos && npm run pack:rename",
173173
"pack:linux": "oclif pack deb && npm run pack:rename",
174174
"pack:tarballs": "oclif pack tarballs -t linux-x64 && npm run pack:rename",
175+
"pack:tarballs:alpine": "oclif pack tarballs -t linux-x64 && npm run pack:rename alpine",
175176
"pack:windows": "oclif pack win && npm run pack:rename",
176177
"pack:rename": "node scripts/releasePackagesRename.js",
177178
"prepublishOnly": "npm run build",

scripts/releasePackagesRename.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ async function renameDeb({version, name, sha}) {
3737
await checkAndRenameFile(generatedPath, newPath);
3838
}
3939

40-
async function renameTar({version, name, sha}) {
40+
async function renameTar({version, name, sha, isAlpine}) {
4141
const dist = 'dist';
4242

4343
const generatedPath = path.resolve(dist, `${name}-v${version}-${sha}-linux-x64.tar.gz`);
4444
// for tarballs, the files are generated in `dist/` directory.
4545
// Creates a new `tar` directory(`dist/tar`), and moves the generated tarball inside that directory.
4646
const tarDirectory = path.resolve(dist, 'tar');
4747
await createDirectory(tarDirectory);
48-
const newPath = path.resolve(tarDirectory, 'asyncapi.tar.gz');
48+
49+
const fileName = isAlpine ? 'asyncapi-alpine.tar.gz' : 'asyncapi.tar.gz';
50+
const newPath = path.resolve(tarDirectory, fileName);
4951
await checkAndRenameFile(generatedPath, newPath);
5052
}
5153

@@ -69,12 +71,18 @@ async function renamePackages() {
6971
const version = packageJson.version;
7072
const name = 'asyncapi';
7173
const sha = await git.revparse(['--short', 'HEAD']);
72-
await renameDeb({version: version.split('-')[0], name, sha});
73-
await renamePkg({version, name, sha, arch: 'x64'});
74-
await renamePkg({version, name, sha, arch: 'arm64'});
75-
await renameWindows({version, name, sha, arch: 'x64'});
76-
await renameWindows({version, name, sha, arch: 'x86'});
77-
await renameTar({version, name, sha});
74+
const isAlpine = process.argv.includes('alpine');
75+
76+
if (isAlpine) {
77+
await renameTar({version, name, sha, isAlpine: true});
78+
} else {
79+
await renameDeb({version: version.split('-')[0], name, sha});
80+
await renamePkg({version, name, sha, arch: 'x64'});
81+
await renamePkg({version, name, sha, arch: 'arm64'});
82+
await renameWindows({version, name, sha, arch: 'x64'});
83+
await renameWindows({version, name, sha, arch: 'x86'});
84+
await renameTar({version, name, sha, isAlpine: false});
85+
}
7886
}
7987

8088
renamePackages();

0 commit comments

Comments
 (0)