mirror of
https://github.com/nocobase/nocobase
synced 2024-11-14 22:15:10 +00:00
chore(ci): optimize
This commit is contained in:
parent
4203b7c7d5
commit
2989215d0f
30
.github/workflows/changelog-and-release.yml
vendored
30
.github/workflows/changelog-and-release.yml
vendored
@ -22,31 +22,33 @@ jobs:
|
||||
write-changelog-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get info
|
||||
id: get-info
|
||||
run: |
|
||||
if [[ "${{ inputs.version }}" == "alpha" ]]; then
|
||||
echo "branch=$(echo 'next')" >> $GITHUB_OUTPUT
|
||||
echo "proRepos=$(echo '${{ vars.NEXT_PRO_PLUGIN_REPOS }}')" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "branch=$(echo 'main')" >> $GITHUB_OUTPUT
|
||||
echo "proRepos=$(echo '${{ vars.PRO_PLUGIN_REPOS }}')" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.NOCOBASE_APP_ID }}
|
||||
private-key: ${{ secrets.NOCOBASE_APP_PRIVATE_KEY }}
|
||||
repositories: nocobase,pro-plugins,${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ',') }}
|
||||
repositories: nocobase,pro-plugins,${{ join(fromJSON(steps.get-info.outputs.proRepos), ',') }}
|
||||
skip-token-revoke: true
|
||||
- name: Get GitHub App User ID
|
||||
id: get-user-id
|
||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
- name: Get branch
|
||||
id: get-branch
|
||||
run: |
|
||||
if [[ "${{ inputs.version }}" == "alpha" ]]; then
|
||||
echo "branch=$(echo 'next')" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "branch=$(echo 'main')" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: nocobase/nocobase
|
||||
ref: ${{ steps.get-branch.outputs.branch }}
|
||||
ref: ${{ steps.get-info.outputs.branch }}
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
persist-credentials: true
|
||||
fetch-depth: 0
|
||||
@ -55,16 +57,16 @@ jobs:
|
||||
with:
|
||||
repository: nocobase/pro-plugins
|
||||
path: packages/pro-plugins
|
||||
ref: ${{ steps.get-branch.outputs.branch }}
|
||||
ref: ${{ steps.get-info.outputs.branch }}
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
persist-credentials: true
|
||||
- name: Clone pro repos
|
||||
shell: bash
|
||||
run: |
|
||||
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
|
||||
for repo in ${{ join(fromJSON(steps.get-info.outputs.proRepos), ' ') }}
|
||||
do
|
||||
git clone -b ${{ steps.get-branch.outputs.branch }} https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/nocobase/$repo.git packages/pro-plugins/@nocobase/$repo
|
||||
git clone -b ${{ steps.get-info.outputs.branch }} https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/nocobase/$repo.git packages/pro-plugins/@nocobase/$repo
|
||||
done
|
||||
- name: Set user
|
||||
run: |
|
||||
@ -81,7 +83,7 @@ jobs:
|
||||
run: |
|
||||
node scripts/release/changelogAndRelease.js --ver ${{ inputs.version }} --cmsURL ${{ secrets.CMS_URL }} --cmsToken ${{ secrets.CMS_TOKEN }}
|
||||
env:
|
||||
PRO_PLUGIN_REPOS: ${{ vars.PRO_PLUGIN_REPOS }}
|
||||
PRO_PLUGIN_REPOS: ${{ steps.get-info.outputs.proRepos }}
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
- name: Commit and push
|
||||
run: |
|
||||
|
31
.github/workflows/manual-build-pro-image.yml
vendored
31
.github/workflows/manual-build-pro-image.yml
vendored
@ -88,23 +88,24 @@ jobs:
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
driver-opts: network=host
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
nocobase/nocobase
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
- name: Login to Aliyun Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ secrets.ALI_DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.ALI_DOCKER_USERNAME }}
|
||||
password: ${{ secrets.ALI_DOCKER_PASSWORD }}
|
||||
- name: Get tag
|
||||
id: get-tag
|
||||
run: |
|
||||
if [ "${{ inputs.pr_number }}" != "" ]; then
|
||||
echo "tag=pr-${{ inputs.pr_number }}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "tag=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Set tags
|
||||
id: set-tags
|
||||
run: |
|
||||
echo "::set-output name=tags::${{ secrets.ALI_DOCKER_REGISTRY }}/nocobase/nocobase:${{ steps.get-tag.outputs.tag }}-pro
|
||||
- name: Set variables
|
||||
run: |
|
||||
target_directory="./packages/pro-plugins/@nocobase"
|
||||
@ -117,7 +118,7 @@ jobs:
|
||||
echo "var1=$BEFORE_PACK_NOCOBASE" >> $GITHUB_OUTPUT
|
||||
echo "var2=$APPEND_PRESET_LOCAL_PLUGINS" >> $GITHUB_OUTPUT
|
||||
id: vars
|
||||
- name: Build and push - pr-${{ inputs.pr_number }}-pro
|
||||
- name: Build and push - ${{ steps.get-tag.outputs.tag }}-pro
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
@ -129,12 +130,12 @@ jobs:
|
||||
BEFORE_PACK_NOCOBASE=${{ steps.vars.outputs.var1 }}
|
||||
APPEND_PRESET_LOCAL_PLUGINS=${{ steps.vars.outputs.var2 }}
|
||||
push: true
|
||||
tags: ${{ secrets.ALI_DOCKER_REGISTRY }}/nocobase/nocobase:pr-${{ inputs.pr_number }}-pro
|
||||
tags: ${{ steps.set-tags.outputs.tags }}
|
||||
- name: Deploy NocoBase
|
||||
run: |
|
||||
curl --retry 2 --location --request POST "${{secrets.NOCOBASE_DEPLOY_HOST}}pr-${{ inputs.pr_number }}-pro" \
|
||||
curl --retry 2 --location --request POST "${{secrets.NOCOBASE_DEPLOY_HOST}}${{ steps.get-tag.outputs.tag }}-pro" \
|
||||
--header 'Content-Type: application/json' \
|
||||
-d "{
|
||||
\"tag\": \"pr-${{ inputs.pr_number }}-pro\",
|
||||
\"tag\": \"${{ steps.get-tag.outputs.tag }}-pro\",
|
||||
\"dialect\": \"postgres\"
|
||||
}"
|
||||
|
204
.github/workflows/release-next.yml
vendored
204
.github/workflows/release-next.yml
vendored
@ -6,6 +6,9 @@ concurrency:
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- chore/ci
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
@ -29,71 +32,71 @@ jobs:
|
||||
with:
|
||||
ref: next
|
||||
fetch-depth: 0
|
||||
- name: Send curl request and parse response
|
||||
env:
|
||||
PKG_USERNAME: ${{ secrets.PKG_USERNAME }}
|
||||
PKG_PASSWORD: ${{ secrets.PKG_PASSWORD }}
|
||||
run: |
|
||||
mkdir git-ci-cache
|
||||
apt-get update && apt-get install -y jq gh
|
||||
response1=$(curl -s 'https://pkg.nocobase.com/-/verdaccio/sec/login' \
|
||||
-H 'content-type: application/json' \
|
||||
--data-raw '{"username":"'$PKG_USERNAME'","password":"'$PKG_PASSWORD'"}')
|
||||
token1=$(echo $response1 | jq -r '.token')
|
||||
response2=$(curl -s 'https://pkg-src.nocobase.com/-/verdaccio/sec/login' \
|
||||
-H 'content-type: application/json' \
|
||||
--data-raw '{"username":"'$PKG_USERNAME'","password":"'$PKG_PASSWORD'"}')
|
||||
token2=$(echo $response2 | jq -r '.token')
|
||||
echo "PKG_NOCOBASE_TOKEN=$token1" >> $GITHUB_ENV
|
||||
echo "PKG_SRC_NOCOBASE_TOKEN=$token2" >> $GITHUB_ENV
|
||||
- name: restore cache
|
||||
id: cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ./git-ci-cache
|
||||
key: new-next-version-${{ github.run_id }}
|
||||
- name: Set NEWVERSION variable
|
||||
id: set_version
|
||||
run: |
|
||||
cd ./git-ci-cache
|
||||
if [ -f newversion.txt ]; then
|
||||
NEWVERSION=$(cat newversion.txt)
|
||||
else
|
||||
NEWVERSION=$(cat ../lerna.json | jq -r '.version').$(date +'%Y%m%d%H%M%S')
|
||||
echo "$NEWVERSION" > newversion.txt
|
||||
fi
|
||||
echo "NEWVERSION=$NEWVERSION" >> $GITHUB_ENV
|
||||
- name: Print NEWVERSION
|
||||
run: echo "The new version is ${{ env.NEWVERSION }}"
|
||||
- name: Save NEWVERSION to cache
|
||||
run: echo "NEWVERSION=$NEWVERSION" >> ./git-ci-cache/newversion.txt
|
||||
- name: save cache
|
||||
id: save-cache
|
||||
uses: actions/cache/save@v3
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
with:
|
||||
path: ./git-ci-cache
|
||||
key: new-next-version-${{ github.run_id }}
|
||||
- name: publish npmjs.org
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
|
||||
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
|
||||
git config --global --add safe.directory /__w/nocobase/nocobase
|
||||
npm config set access public
|
||||
npm config set registry https://registry.npmjs.org/
|
||||
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
||||
yarn config set access public
|
||||
yarn config set registry https://registry.npmjs.org/
|
||||
yarn config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
||||
yarn install
|
||||
yarn lerna version ${{ env.NEWVERSION }} -y --no-git-tag-version
|
||||
yarn build
|
||||
echo "# test" >> Release.md
|
||||
git add .
|
||||
git commit -m "chore(versions): test publish packages xxx"
|
||||
cat lerna.json
|
||||
yarn release:force --no-verify-access --no-git-reset --registry https://registry.npmjs.org/ --dist-tag=next
|
||||
# - name: Send curl request and parse response
|
||||
# env:
|
||||
# PKG_USERNAME: ${{ secrets.PKG_USERNAME }}
|
||||
# PKG_PASSWORD: ${{ secrets.PKG_PASSWORD }}
|
||||
# run: |
|
||||
# mkdir git-ci-cache
|
||||
# apt-get update && apt-get install -y jq gh
|
||||
# response1=$(curl -s 'https://pkg.nocobase.com/-/verdaccio/sec/login' \
|
||||
# -H 'content-type: application/json' \
|
||||
# --data-raw '{"username":"'$PKG_USERNAME'","password":"'$PKG_PASSWORD'"}')
|
||||
# token1=$(echo $response1 | jq -r '.token')
|
||||
# response2=$(curl -s 'https://pkg-src.nocobase.com/-/verdaccio/sec/login' \
|
||||
# -H 'content-type: application/json' \
|
||||
# --data-raw '{"username":"'$PKG_USERNAME'","password":"'$PKG_PASSWORD'"}')
|
||||
# token2=$(echo $response2 | jq -r '.token')
|
||||
# echo "PKG_NOCOBASE_TOKEN=$token1" >> $GITHUB_ENV
|
||||
# echo "PKG_SRC_NOCOBASE_TOKEN=$token2" >> $GITHUB_ENV
|
||||
# - name: restore cache
|
||||
# id: cache
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: ./git-ci-cache
|
||||
# key: new-next-version-${{ github.run_id }}
|
||||
# - name: Set NEWVERSION variable
|
||||
# id: set_version
|
||||
# run: |
|
||||
# cd ./git-ci-cache
|
||||
# if [ -f newversion.txt ]; then
|
||||
# NEWVERSION=$(cat newversion.txt)
|
||||
# else
|
||||
# NEWVERSION=$(cat ../lerna.json | jq -r '.version').$(date +'%Y%m%d%H%M%S')
|
||||
# echo "$NEWVERSION" > newversion.txt
|
||||
# fi
|
||||
# echo "NEWVERSION=$NEWVERSION" >> $GITHUB_ENV
|
||||
# - name: Print NEWVERSION
|
||||
# run: echo "The new version is ${{ env.NEWVERSION }}"
|
||||
# - name: Save NEWVERSION to cache
|
||||
# run: echo "NEWVERSION=$NEWVERSION" >> ./git-ci-cache/newversion.txt
|
||||
# - name: save cache
|
||||
# id: save-cache
|
||||
# uses: actions/cache/save@v3
|
||||
# if: steps.cache.outputs.cache-hit != 'true'
|
||||
# with:
|
||||
# path: ./git-ci-cache
|
||||
# key: new-next-version-${{ github.run_id }}
|
||||
# - name: publish npmjs.org
|
||||
# continue-on-error: true
|
||||
# run: |
|
||||
# git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
|
||||
# git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
|
||||
# git config --global --add safe.directory /__w/nocobase/nocobase
|
||||
# npm config set access public
|
||||
# npm config set registry https://registry.npmjs.org/
|
||||
# npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
||||
# yarn config set access public
|
||||
# yarn config set registry https://registry.npmjs.org/
|
||||
# yarn config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
||||
# yarn install
|
||||
# yarn lerna version ${{ env.NEWVERSION }} -y --no-git-tag-version
|
||||
# yarn build
|
||||
# echo "# test" >> Release.md
|
||||
# git add .
|
||||
# git commit -m "chore(versions): test publish packages xxx"
|
||||
# cat lerna.json
|
||||
# yarn release:force --no-verify-access --no-git-reset --registry https://registry.npmjs.org/ --dist-tag=next
|
||||
- name: Checkout pro-plugins
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
@ -109,44 +112,45 @@ jobs:
|
||||
do
|
||||
git clone -b next https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/nocobase/$repo.git packages/pro-plugins/@nocobase/$repo
|
||||
done
|
||||
- name: Build Pro plugins
|
||||
run: |
|
||||
yarn config set registry https://registry.npmjs.org/
|
||||
yarn install
|
||||
yarn lerna version ${{ env.NEWVERSION }} -y --no-git-tag-version
|
||||
yarn build packages/pro-plugins
|
||||
- name: publish pkg.nocobase.com
|
||||
run: |
|
||||
git reset --hard
|
||||
npm config set //pkg.nocobase.com/:_authToken=${{ env.PKG_NOCOBASE_TOKEN }}
|
||||
yarn release:force --no-verify-access --no-git-reset --registry https://pkg.nocobase.com --dist-tag=next
|
||||
- name: publish pkg-src.nocobase.com
|
||||
run: |
|
||||
git reset --hard
|
||||
bash generate-npmignore.sh ignore-src
|
||||
npm config set //pkg-src.nocobase.com/:_authToken=${{ env.PKG_SRC_NOCOBASE_TOKEN }}
|
||||
yarn release:force --no-verify-access --no-git-reset --registry https://pkg-src.nocobase.com --dist-tag=next
|
||||
- name: Tag
|
||||
run: |
|
||||
git reset --hard HEAD~
|
||||
git tag v${{ env.NEWVERSION }}
|
||||
git push origin v${{ env.NEWVERSION }}
|
||||
cd ./packages/pro-plugins
|
||||
git reset --hard
|
||||
git tag v${{ env.NEWVERSION }}
|
||||
git push origin v${{ env.NEWVERSION }}
|
||||
cd ../../
|
||||
for repo in ${{ join(fromJSON(vars.NEXT_PRO_PLUGIN_REPOS), ' ') }} ${{ join(fromJSON(vars.CUSTOM_PRO_PLUGIN_REPOS), ' ') }}
|
||||
do
|
||||
cd ./packages/pro-plugins/@nocobase/$repo
|
||||
git reset --hard
|
||||
git tag v${{ env.NEWVERSION }}
|
||||
git push origin v${{ env.NEWVERSION }}
|
||||
cd ../../../../
|
||||
done
|
||||
# - name: Build Pro plugins
|
||||
# run: |
|
||||
# yarn config set registry https://registry.npmjs.org/
|
||||
# yarn install
|
||||
# yarn lerna version ${{ env.NEWVERSION }} -y --no-git-tag-version
|
||||
# yarn build packages/pro-plugins
|
||||
# - name: publish pkg.nocobase.com
|
||||
# run: |
|
||||
# git reset --hard
|
||||
# npm config set //pkg.nocobase.com/:_authToken=${{ env.PKG_NOCOBASE_TOKEN }}
|
||||
# yarn release:force --no-verify-access --no-git-reset --registry https://pkg.nocobase.com --dist-tag=next
|
||||
# - name: publish pkg-src.nocobase.com
|
||||
# run: |
|
||||
# git reset --hard
|
||||
# bash generate-npmignore.sh ignore-src
|
||||
# npm config set //pkg-src.nocobase.com/:_authToken=${{ env.PKG_SRC_NOCOBASE_TOKEN }}
|
||||
# yarn release:force --no-verify-access --no-git-reset --registry https://pkg-src.nocobase.com --dist-tag=next
|
||||
# - name: Tag
|
||||
# run: |
|
||||
# git reset --hard HEAD~
|
||||
# git tag v${{ env.NEWVERSION }}
|
||||
# git push origin v${{ env.NEWVERSION }}
|
||||
# cd ./packages/pro-plugins
|
||||
# git reset --hard
|
||||
# git tag v${{ env.NEWVERSION }}
|
||||
# git push origin v${{ env.NEWVERSION }}
|
||||
# cd ../../
|
||||
# for repo in ${{ join(fromJSON(vars.NEXT_PRO_PLUGIN_REPOS), ' ') }} ${{ join(fromJSON(vars.CUSTOM_PRO_PLUGIN_REPOS), ' ') }}
|
||||
# do
|
||||
# cd ./packages/pro-plugins/@nocobase/$repo
|
||||
# git reset --hard
|
||||
# git tag v${{ env.NEWVERSION }}
|
||||
# git push origin v${{ env.NEWVERSION }}
|
||||
# cd ../../../../
|
||||
# done
|
||||
- name: Run release script
|
||||
shell: bash
|
||||
run: |
|
||||
yarn install
|
||||
git fetch
|
||||
node scripts/release/changelogAndRelease.js --ver alpha --cmsURL ${{ secrets.CMS_URL }} --cmsToken ${{ secrets.CMS_TOKEN }}
|
||||
env:
|
||||
|
@ -344,11 +344,11 @@ async function createRelease(cn, en, to) {
|
||||
}
|
||||
let { ver = 'beta' } = program.opts();
|
||||
// gh release create -t title -n note
|
||||
if (ver === 'alpha') {
|
||||
await execa('gh', ['release', 'create', to, '-t', to, '-n', en, '-p']);
|
||||
return;
|
||||
}
|
||||
await execa('gh', ['release', 'create', to, '-t', to, '-n', en]);
|
||||
// if (ver === 'alpha') {
|
||||
// await execa('gh', ['release', 'create', to, '-t', to, '-n', en, '-p']);
|
||||
// return;
|
||||
// }
|
||||
// await execa('gh', ['release', 'create', to, '-t', to, '-n', en]);
|
||||
}
|
||||
|
||||
async function getExistsChangelog(from, to) {
|
||||
@ -381,7 +381,7 @@ async function getVersion() {
|
||||
return { from, to };
|
||||
}
|
||||
|
||||
async function postCMS(title, content, contentCN) {
|
||||
async function postCMS(tag, content, contentCN) {
|
||||
const { cmsToken, cmsURL } = program.opts();
|
||||
if (!cmsToken || !cmsURL) {
|
||||
console.error('No cmsToken or cmsURL provided');
|
||||
@ -394,13 +394,16 @@ async function postCMS(title, content, contentCN) {
|
||||
Authorization: `Bearer ${cmsToken}`,
|
||||
},
|
||||
params: {
|
||||
filterKeys: ['title'],
|
||||
filterKeys: ['slug'],
|
||||
},
|
||||
data: {
|
||||
title,
|
||||
title_cn: title,
|
||||
slug: tag,
|
||||
title: `Nocobase ${tag}`,
|
||||
title_cn: `Nocobase ${tag}`,
|
||||
content,
|
||||
content_cn: contentCN,
|
||||
description: `Release Note of ${tag}`,
|
||||
description_cn: `${tag} 更新日志`,
|
||||
tags: [4],
|
||||
status: 'drafted',
|
||||
author: 'nocobase [bot]',
|
||||
@ -432,10 +435,10 @@ async function writeChangelogAndCreateRelease() {
|
||||
return;
|
||||
}
|
||||
if (ver === 'beta' && !exists) {
|
||||
await writeChangelog(cn, en, from, to);
|
||||
// await writeChangelog(cn, en, from, to);
|
||||
}
|
||||
await createRelease(cn, en, to);
|
||||
await postCMS(to, en, cn);
|
||||
// await postCMS(to, en, cn);
|
||||
}
|
||||
|
||||
writeChangelogAndCreateRelease();
|
||||
|
Loading…
Reference in New Issue
Block a user