Skip to content

Commit

Permalink
publish workflow (#25)
Browse files Browse the repository at this point in the history
* publish workflow

Signed-off-by: zxypro1 <[email protected]>

* update workflow
feat: remove `project` in `env.yaml`

Signed-off-by: zxypro1 <[email protected]>

* publish: [email protected], [email protected]

Signed-off-by: zxypro1 <[email protected]>

---------

Signed-off-by: zxypro1 <[email protected]>
  • Loading branch information
zxypro1 authored Jan 26, 2024
1 parent 75c693f commit abb7530
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 7 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/publish-pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish Packages

on:
push:
branches:
- main
paths:
- 'packages/*/package.json'

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
package:
- component-interface
- component-manager
- credential
- diff
- downloads
- engine
- ignore-walk
- load-application
- load-component
- logger
- orm
- parse-spec
- progress-bar
- registry
- utils
- zip

steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm run install:all

- name: Build packages
run: npm run build

- name: Publish package
run: |
PACKAGE_DIR=packages/${{ matrix.package }}
PACKAGE_JSON="${PACKAGE_DIR}/package.json"
# 检查 package.json 是否被修改
if git diff HEAD^ HEAD --name-only | grep -q "${PACKAGE_JSON}"; then
echo "Publishing ${{ matrix.package }}..."
cd $PACKAGE_DIR
npm run pub
else
echo "No changes in ${{ matrix.package }}/package.json"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- '*@*' # 书写格式:[email protected]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 16.x

- run: npx changelogithub # or [email protected] if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.CUSTOM_GITHUB_TOKEN}}
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
# toolkit for serverless-devs

## [@serverless-devs/downloads](./packages/downloads/README.md)
![整体架构图](./assets/overall-arch.png)

### [@serverless-devs/downloads](./packages/downloads/README.md)

- 下载,支持文件解压等功能
## [@serverless-devs/load-application](./packages/load-application/README.md)
- 下载应用, 仅适用于serverless源的应用。

### [@serverless-devs/load-application](./packages/load-application/README.md)

- 下载应用, 仅适用于serverless源的应用。

### [@serverless-devs/engine](./packages/engine/README.md)

- 核心,掌管所有第三方组件命令的具体执行。

### [@serverless-devs/parse-spec](./packages/parse-spec/README.md)

- 配置文件解析,任务编排,处理后交由Engine执行。

### [@serverless-devs/logger](./packages/logger/README.md)

- 掌管全局日志的输入和输出,读取和写入。

### [@serverless-devs/credential](./packages/credential/README.md)

- 全局身份认证。

### [@serverless-devs/load-component](./packages/load-component/README.md)

- 从下载源中下载特定组件。目前只保留了serverless registry源

### [@serverless-devs/registry](./packages/registry/README.md)

- Serverless Registry内容管理

## 开发

```shell
npm run install:all #依赖安装
npm run build #编译所有包
npm run test #测试
```

## 发布

### 发布到npm

- 修改package.json中的版本号。
- 提pr到main。确保通过ci。
- 合并后,将触发流水线自动发布。

### Github Release

- 打tag并上传,格式为`xxx(包名,如engine)@x.x.x(版本号,如0.0.1)`
- 将自动触发流水线进行release。
Binary file added assets/overall-arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/engine",
"version": "0.0.25",
"version": "0.0.26",
"description": "a engine lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/parse-spec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/parse-spec",
"version": "0.0.21",
"version": "0.0.22",
"description": "a parse yaml spec lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions packages/parse-spec/src/contants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const REGXG = /\${([\w\W]*?)}/g;
export const ENVIRONMENT_KEY = 'env';
export const ENVIRONMENT_FILE_NAME = 'env.yaml';
export const ENVIRONMENT_FILE_PATH = path.join(utils.getRootHome(), 'cache', 'default-env.json');
// Aliyun Serverless Devs 远程项目名称
export const ALIYUN_REMOTE_PROJECT_ENV_PARAM = 'ALIYUN_DEVS_REMOTE_PROJECT_NAME';
10 changes: 8 additions & 2 deletions packages/parse-spec/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ class ParseSpec {
trackerType: ETrackerType.parseException,
});
}
const { project, environments } = envYamlContent;
const { environments } = envYamlContent;
// 若存在环境变量,默认项目为devsProject
const devsProject = process.env.ALIYUN_DEVS_REMOTE_PROJECT_NAME;
const project = devsProject ? devsProject : get(this.yaml.content, 'name');
const defaultEnvContent = require(ENVIRONMENT_FILE_PATH);
const defaultEnv = get(find(defaultEnvContent, { project: project }), 'default');
// project is not found in default-env.json
Expand Down Expand Up @@ -178,7 +181,10 @@ class ParseSpec {
});
}
debug(`environment content: ${JSON.stringify(envYamlContent)}`);
const { project, environments } = envYamlContent;
const { environments } = envYamlContent;
// 若存在环境变量,默认项目为devsProject
const devsProject = process.env.ALIYUN_DEVS_REMOTE_PROJECT_NAME;
const project = devsProject ? devsProject : get(this.yaml.content, 'name');
const environment = find(environments, item => item.name === this.record.env);
// env name is not found
if (isEmpty(environment)) {
Expand Down

0 comments on commit abb7530

Please sign in to comment.