Skip to content

Commit

Permalink
update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Feb 13, 2024
1 parent 18a34f7 commit f6b43b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 63 deletions.
64 changes: 8 additions & 56 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ on:
jobs:
build:
name: Build
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || '' }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || '' }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: 'deploy'
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install xvfb
Expand All @@ -31,57 +24,16 @@ jobs:
- name: Build for Distribution
run: xvfb-run --auto-servernum npm run dist

# All the below are deploy-related steps
- name: Extract Branch Name
id: branch_name
if: github.event_name == 'push' && !contains(github.ref, 'refs/tags')
run: echo BRANCH_NAME=${GITHUB_REF/refs\/heads\//} >> $GITHUB_OUTPUT

# Examples:
# 1) PR feature/acme merged into dev
# 2) branch A merged into branch B
# 3) branch A pushed directly to git
- name: Deploy Non-Tag Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'push' && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=60"
env:
DEST_DIR: ${{ steps.branch_name.outputs.BRANCH_NAME }}

# Release is published and deployed into s3://bucket-name/v5.22/
- name: Deploy Released Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && env.AWS_ACCESS_KEY_ID != ''
- name: Upload chrome extension
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=2592000"
env:
DEST_DIR: ${{ github.event.release.tag_name }}

# Same release from previous deployed into s3://bucket-name/release/
- name: Deploy Latest Release
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && github.event.release.prerelease == false && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=1209600"
env:
DEST_DIR: 'latest'

# Publish to NPM
- name: Publish Latest Release
if: github.event_name == 'release' && github.event.release.prerelease == false && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci

# Publish to NPM with prerelease dist-tag
- name: Publish Latest Prerelease
if: github.event_name == 'release' && github.event.release.prerelease && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci
env:
XS_PUBLISH_TAG: prerelease
name: upload
path: .upload/

# Automatically attach browser files to release
# Automatically attach files to release
- name: Upload to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: dist/*
files: .upload/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,5 @@ dist
./lib
deploy
.DS_Store
/out
/out
.upload
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@
"prebuild": "npm run clean",
"build": "run-p build:*",
"build:chrome": "vite build --config vite.chrome.config.ts",
"build:example": "vite build --config vite.example.config.ts",
"build:lib": "vite build --config vite.inject.config.ts",
"postbuild": "mkdir -p .upload && zip -r chrome.zip ./dist/chrome/* && mv chrome.zip .upload/",
"start": "run-p watch:*",
"watch": "run-p watch:*",
"watch:example": "vite dev --config vite.example.config.ts",
"watch:chrome": "vite dev --config vite.chrome.config.ts",
"watch:lib": "vite build --config vite.inject.config.ts --watch",
"dist": "run-s build",
"postdist": "run-s copy:*",
"copy:dist": "copyfiles -u 1 dist/* deploy",
"copy:assets": "copyfiles \"{dist,docs,examples}/**\" deploy",
"deploy": "run-s clean build && xs deploy",
"deploy": "run-s clean build",
"release": "xs bump,test && run-s deploy && xs git-push",
"publish-ci": "xs publish",
"prettier": "prettier . --write"
},
"pre-commit": [
Expand Down

0 comments on commit f6b43b4

Please sign in to comment.