New github's action to download dependencies archive.

To be used by other projects instead of the small bash script we currently have.
This commit is contained in:
Matthieu Gautier 2023-12-01 11:32:04 +01:00
parent 2f39aedfa6
commit b97bd8e4ed
6 changed files with 30821 additions and 0 deletions

View File

@ -0,0 +1,55 @@
# Download dependencies archive action
This action download dependencies archive made by kiwix-build.
It is intended to be used in projects using theses dependencies
## Inputs
### `base_url`
The base url where we can download the archive.
This input is provided for greater customization but you probably shouldn't set it.
### `os_name`
The os "name" on which the compilation is done.
By default this use the `OS_NAME` env var, which is set in the docker file.
### `target_platform`
**Required** The targeted platform. Must be provided. Values are kind of :
- native_dyn
- android_arm
- ...
### `project`
The name of the project being compiled.
By default, the name of the repository.
### `branch`
The name of the "branch" to try to download (`/dev_preview/<branch>`).
By default, the current branch on which the action is run.
### `extract_dir`
Where to extract the dependencies archive. By default it is `$HOME`
## Example usage
```yaml
uses: kiwix/kiwix-build/actions/dl_deps_archive@main
with:
target_platform: ${{ matrix.target_platform }}
```
```
uses: kiwix/kiwix-build/actions/dl_deps_archive@main
with:
target_platform: native_mixed
os_name: windows
```

View File

@ -0,0 +1,25 @@
name: 'DL deps archive'
description: 'Download the dependencies archive of the project'
inputs:
base_url: # id of input
description: 'What is the base url to download the archive'
required: false
default: 'https://tmp.kiwix.org/ci'
os_name:
description: "On which os are we running. [Default to env var `OS_NAME`]"
required: false
target_platform:
description: "What platform are we targetting"
required: true
project:
description: "What project are we building"
required: false
branch:
description: "On which branch are we ?"
required: false
extract_dir:
description: "Where to extract our dependencies. [Default to env var `HOME`]"
required: false
runs:
using: 'node20'
main: 'dist/index.js'

30564
actions/dl_deps_archive/dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,48 @@
const tc = require('@actions/tool-cache');
const core = require('@actions/core');
import * as path from 'path'
function getInput(name, dflt) {
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`];
if (!val) {
return dflt;
}
return val;
}
function addLocalPath(inputPath) {
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`
}
async function run() {
try {
const base_url = core.getInput('base_url');
const os_name = getInput('os_name', process.env['OS_NAME']);
const target = core.getInput('target_platform');
const project = getInput('project', process.env['GITHUB_REPOSITORY'].split('/')[1]);
const branch = getInput('branch', process.env['GITHUB_HEAD_REF']||process.env['GITHUB_REF_NAME']);
const extract_dir = getInput('extract_dir', process.env['HOME']||process.env['GITHUB_WORKSPACE']);
let archivePath;
try {
const archive_url = `${base_url}/dev_preview/${branch}/deps2_${os_name}_${target}_${project}.tar.xz`;
process.stdout.write("Downloading " + archive_url + "\n");
archivePath = await tc.downloadTool(archive_url);
} catch (error) {
const archive_url = `${base_url}/deps2_${os_name}_${target}_${project}.tar.xz`;
process.stdout.write("Downloading " + archive_url + "\n");
archivePath = await tc.downloadTool(archive_url);
}
process.stdout.write("Extracting " + archivePath + " to " + extract_dir);
const archive_dir = await tc.extractTar(archivePath, extract_dir, 'xa');
process.stdout.write("Extracted to " + archive_dir);
} catch (error) {
core.setFailed(error.message);
}
}
addLocalPath('C:\\Program Files\\Git\\usr\\bin');
core.setCommandEcho(true);
run()

113
actions/dl_deps_archive/package-lock.json generated Normal file
View File

@ -0,0 +1,113 @@
{
"name": "dl_deps_archive",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dl_deps_archive",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/tool-cache": "^2.0.1"
}
},
"node_modules/@actions/core": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz",
"integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
},
"node_modules/@actions/tool-cache": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1",
"semver": "^6.1.0",
"uuid": "^3.3.2"
}
},
"node_modules/@actions/tool-cache/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
"engines": {
"node": ">=14"
}
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/undici": {
"version": "5.28.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz",
"integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
}
}
}

View File

@ -0,0 +1,16 @@
{
"name": "dl_deps_archive",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/tool-cache": "^2.0.1"
}
}