initial commit
This commit is contained in:
parent
52f1dcc155
commit
7bd747c85d
14
.github/workflows/ci.yml
vendored
Normal file
14
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Testing:
|
||||
runs-on: ubuntu-latest
|
||||
name: Test the action
|
||||
steps:
|
||||
- name: Setup PDM
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.6
|
||||
# Use the output from the `hello` step
|
||||
- name: Get the project info
|
||||
run: pdm info
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
yarn.lock
|
||||
__pypackages__/
|
2
.pdm.toml
Normal file
2
.pdm.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[python]
|
||||
path = "/Users/fming/Library/PythonUp/cmd/python3.8"
|
@ -1,2 +1,3 @@
|
||||
# pdm-action
|
||||
# Setup PDM for GitHub Action
|
||||
|
||||
The GitHub Action for using pdm as the package manager
|
||||
|
21
action.yml
Normal file
21
action.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
name: 'Setup PDM'
|
||||
description: 'Set up a specific version of PDM and uses a given Python version to work on'
|
||||
author: 'Frost Ming'
|
||||
inputs:
|
||||
python-version:
|
||||
description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
|
||||
default: '3.x'
|
||||
architecture:
|
||||
description: 'The target architecture (x86, x64) of the Python interpreter.'
|
||||
token:
|
||||
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
||||
default: ${{ github.token }}
|
||||
version:
|
||||
description: The version of PDM to install.
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'index.js'
|
||||
branding:
|
||||
icon: 'code'
|
||||
color: 'green'
|
30
index.js
Normal file
30
index.js
Normal file
@ -0,0 +1,30 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
import * as setupPython from "setup-python/dist";
|
||||
import * as os from "os";
|
||||
import { exec as execChild } from "child_process";
|
||||
|
||||
const INSTALL_VERSION = "3.8";
|
||||
|
||||
async function run() {
|
||||
const arch = core.getInput("architecture") || os.arch();
|
||||
const pdmVersion = core.getInput("version");
|
||||
const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : "pdm";
|
||||
try {
|
||||
await setupPython.findPythonVersion(INSTALL_VERSION, arch);
|
||||
await exec.exec("python", ["-m", "pip", "install", "-U", pdmPackage]);
|
||||
const installed = await setupPython.findPythonVersion(
|
||||
core.getInput("python-version"),
|
||||
arch
|
||||
);
|
||||
await exec.exec("pdm", ["use", "-f", installed.version]);
|
||||
const pdmVersionOutput = (await execChild("pdm --version")).stdout;
|
||||
core.info(
|
||||
`Successfully setup ${pdmVersionOutput} with Python ${installed.version}`
|
||||
);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
23
package.json
Normal file
23
package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "pdm-action",
|
||||
"version": "1.0.0",
|
||||
"description": "The GitHub Action for using pdm as the package manager",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pdm-project/pdm-action.git"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"setup-python": "actions/setup-python"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.31",
|
||||
"typescript": "^4.2.2"
|
||||
}
|
||||
}
|
22
pyproject.toml
Normal file
22
pyproject.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[project]
|
||||
name = ""
|
||||
version = ""
|
||||
description = ""
|
||||
authors = [
|
||||
{name = "Frost Ming", email = "mianghong@gmail.com"},
|
||||
]
|
||||
dependencies = []
|
||||
dev-dependencies = []
|
||||
requires-python = ">=3.8"
|
||||
dynamic = ["classifiers"]
|
||||
license = {text = "MIT"}
|
||||
|
||||
[project.urls]
|
||||
homepage = ""
|
||||
|
||||
[tool]
|
||||
[tool.pdm]
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-pep517"]
|
||||
build-backend = "pdm.pep517.api"
|
Loading…
x
Reference in New Issue
Block a user