Skip to content

Commit

Permalink
chore: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Oct 13, 2023
1 parent d8ab29a commit 9293160
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 2,079 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
**/coverage/*
**/node_modules/*
pnpm-lock.yaml
CHANGELOG.md
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

jobs:
build:
build-and-upload-artifact:
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -15,11 +15,13 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Add SSH key to chekout a private repo
uses: webfactory/ssh-agent@v0.7.0
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ssh-private-key: ${{ secrets.REPO_SSH_KEY }}

- name: Setup
- name: Setup 🛠️
uses: ./.github/actions/setup

- name: Build 🔧
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Add SSH key to chekout a private repo
uses: webfactory/ssh-agent@v0.7.0
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ssh-private-key: ${{ secrets.REPO_SSH_KEY }}

- name: Setup 🛠️
uses: ./.github/actions/setup
Expand Down
76 changes: 43 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ on:
options:
- iris-web-rtc
- iris-web-rtm
version:
description: 'x.x.x-semver.x, semver: dev,build'
required: true
default: 'patch'
type: string
releases:
description: 'create Releases, choose false if specify version'
default: true
type: boolean
cdn:
description: 'upload to cdn'
default: true
default: false
type: boolean
release_type:
description: 'The release type of CDN'
default: 'staging'
type: string
npm:
description: 'upload to npm'
default: false
type: boolean

jobs:
release-it:
Expand All @@ -34,54 +47,51 @@ jobs:
- name: Setup
uses: ./.github/actions/setup

- name: Setup Dependencies and Build💚
- name: Setup Dependencies 💚
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: |
pnpm install
pnpm run lint
pnpm run build
OUTPUT_ARTIFACT_FILE_NAME=$(ls packages/rtc/dist | awk -F/ '{print $NF}')
echo "OUTPUT_ARTIFACT_FILE_NAME=$OUTPUT_ARTIFACT_FILE_NAME" >> $GITHUB_ENV
MY_PATH=$(ls packages/rtc/dist | awk -F/ '{print $NF}')
echo "MY_PATH=$MY_PATH" >> $GITHUB_ENV
- name: Upload Artifact ⬆️
uses: actions/upload-artifact@v3
with:
name: iris-web-rtc
path: ./packages/rtc/dist/${{ env.MY_PATH }}

- name: CDN Publish
if: ${{ inputs.cdn }}
run: |
UPLOAD_CDN_INTERNAL_JENKINS_HOOK=${{ inputs.upload_cdn_internal_jenkins_hook }}
UPLOAD_URL=${{ inputs.url }}
RELEASE_TYPE=${{ inputs.release_type }}
curl -X POST ${UPLOAD_CDN_INTERNAL_JENKINS_HOOK} \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{ \"release\": { \"assets\": [ { \"browser_download_url\": \"${UPLOAD_URL}\", \"release_type\": \"${RELEASE_TYPE}\" } ] }}"
shell: bash

- name: Setup NPM auth token
if: ${{ inputs.npm }}
run: |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}
- name: Config Git
if: ${{ inputs.npm }}
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
- name: Get Package Info
if: ${{ inputs.package == 'iris-web-rtc' }}
run: |
version=$(node -p "require('./packages/rtc/package.json').version")
echo "version=${version}" >> $GITHUB_ENV
- name: Get Package Info
if: ${{ inputs.package == 'iris-web-rtm' }}
- name: Update CHANGELOG.md
run: |
version=$(node -p "require('./packages/rtm/package.json').version")
echo "version=${version}" >> $GITHUB_ENV
pnpm release ${{ inputs.version }} --ci --no-git.tag --no-github.release --npm.allowSameVersion
- name: Update CHANGELOG.md and Create Release
run: |
pnpm release ${{ env.version }} --ci --npm.allowSameVersion --github.assets=./packages/rtc/dist/${{ env.OUTPUT_ARTIFACT_FILE_NAME }}
- name: Prepare CDN Publish
if: ${{ inputs.cdn }}
- name: Release and Publish
run: |
GITHUB_RELEASE_DOWNLOAD_PREFIX=https://github.com/AgoraIO-Extensions/iris_web/releases/download
GITHUB_RELEASE_DOWNLOAD_URL="${GITHUB_RELEASE_DOWNLOAD_PREFIX}/v${{ env.version }}/${{ env.OUTPUT_ARTIFACT_FILE_NAME }}"
echo "GITHUB_RELEASE_DOWNLOAD_URL=${GITHUB_RELEASE_DOWNLOAD_URL}" >> $GITHUB_ENV
- name: CDN Publish
if: ${{ inputs.cdn }}
env:
UPLOAD_CDN_INTERNAL_JENKINS_HOOK: ${{ secrets.UPLOAD_CDN_INTERNAL_JENKINS_HOOK }}
uses: AgoraIO-Extensions/actions/.github/actions/upload_cdn_internal@main
with:
upload_cdn_internal_jenkins_hook: ${{ env.UPLOAD_CDN_INTERNAL_JENKINS_HOOK }}
url: ${{ env.GITHUB_RELEASE_DOWNLOAD_URL }}
release_type: ${{ inputs.release_type }}
pnpm release ${{ steps.package-info.outputs.version }} --ci --npm.publish=${{ inputs.npm }} --github.update --github.assets=./packages/rtc/dist/${{ env.MY_PATH }}
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
**/coverage/*
**/node_modules/*
pnpm-lock.yaml
CHANGELOG.md
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# iris-web-rtc
48 changes: 2 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"lint": "eslint --ext .ts,.tsx . && prettier --check .",
"lint:fix": "eslint --fix --ext .ts,.tsx . && prettier --write .",
"terra": "pnpm -F terra-generate run terra",
"start": "sh ./scripts/build_local_dev.sh",
"release": "release-it"
"start": "sh ./scripts/build_local_dev.sh"
},
"pnpm": {
"peerDependencyRules": {
Expand Down Expand Up @@ -38,49 +37,6 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unused-imports": "^3.0.0",
"prettier": "^2.0.5",
"release-it": "^16.1.3",
"@release-it/conventional-changelog": "^7.0.1"
},
"release-it": {
"git": {
"commitMessage": "chore: release ${version}",
"requireCleanWorkingDir": false,
"tagName": "v${version}"
},
"npm": {
"publish": false,
"allowSameVersion": true
},
"github": {
"release": true
},
"hooks": {
"before:init": "git fetch --prune --prune-tags origin",
"before:git:release": "git reset HEAD package.json"
},
"plugins": {
"@release-it/conventional-changelog": {
"header": "# IRIS_WEB",
"preset": {
"name": "conventionalcommits",
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "docs",
"section": "Documentation"
}
]
},
"infile": "CHANGELOG.md"
}
}
"prettier": "^2.0.5"
}
}
46 changes: 2 additions & 44 deletions packages/rtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@
"watch": "webpack --watch",
"start": "webpack serve --open",
"lint": "eslint --ext .ts ./src/binding ./test/binding",
"lint:fix": "eslint --fix --ext .ts ./src/binding ./test/binding",
"release": "release-it"
"lint:fix": "eslint --fix --ext .ts ./src/binding ./test/binding"
},
"author": "guoxianzhe",
"author": "",
"license": "ISC",
"dependencies": {
"@iris/native-rtc-binding": "workspace: *",
"agora-rtc-sdk-ng": "^4.18.2",
"iris-web-core": "workspace: *"
},
"files": [
"dist",
"LICENSE",
"README.md"
],
"devDependencies": {
"@testing-library/jest-dom": "^6.1.3",
"@types/jest": "^29.5.3",
Expand All @@ -39,41 +33,5 @@
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.2"
},
"release-it": {
"git": {
"commitMessage": "chore: release ${version}",
"requireCleanWorkingDir": false,
"tagName": "v${version}"
},
"npm": {
"publish": false,
"allowSameVersion": true
},
"github": {
"release": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {
"name": "conventionalcommits",
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "docs",
"section": "Documentation"
}
]
},
"infile": ""
}
}
}
}
Loading

0 comments on commit 9293160

Please sign in to comment.