Skip to content

Commit

Permalink
meta: add upload-to-cdn workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jul 11, 2024
1 parent d3d0c97 commit efa993f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 17 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/upload-to-cdn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Upload a release from npm to the CDN
on:
workflow_dispatch:
inputs:
package:
description: Package to upload
required: true
type: choice
options:
- uppy
- '@uppy/locales'
version:
description: Version to upload (from npm)
required: true
type: string
force:
description: --force
type: boolean
default: false

env:
YARN_ENABLE_GLOBAL_CACHE: false

jobs:
upload-to-cdn:
name: Upload to CDN
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: corepack yarn workspace focus upload-to-cdn
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- name: Upload "${{ inputs.package }}" to CDN
if: !inputs.force
run: corepack yarn run uploadcdn "$PACKAGE" "$VERSION"
env:
PACKAGE: ${{inputs.package}}
VERSION: ${{inputs.version}}
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- name: Upload "${{ inputs.package }}" to CDN
if: inputs.force
run: corepack yarn run uploadcdn "$PACKAGE" "$VERSION" -- --force
env:
PACKAGE: ${{inputs.package}}
VERSION: ${{inputs.version}}
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"e2e"
],
"devDependencies": {
"@aws-sdk/client-s3": "^3.338.0",
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.11.3",
Expand All @@ -61,11 +60,9 @@
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@uppy-dev/remark-lint-uppy": "workspace:*",
"adm-zip": "^0.5.5",
"autoprefixer": "^10.2.6",
"babel-plugin-inline-package-json": "^2.0.0",
"chalk": "^5.0.0",
"concat-stream": "^2.0.0",
"cssnano": "^7.0.0",
"dotenv": "^16.0.0",
"esbuild": "^0.21.2",
Expand All @@ -91,11 +88,8 @@
"glob": "^8.0.0",
"jsdom": "^24.0.0",
"lint-staged": "^15.0.0",
"mime-types": "^2.1.26",
"npm-packlist": "^5.0.0",
"npm-run-all": "^4.1.5",
"onchange": "^7.1.0",
"pacote": "^13.0.0",
"postcss": "^8.4.31",
"postcss-dir-pseudo-class": "^6.0.0",
"postcss-logical": "^5.0.0",
Expand All @@ -109,7 +103,6 @@
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^13.0.0",
"tar": "^6.1.0",
"typescript": "~5.4",
"vitest": "^1.2.1",
"vue-template-compiler": "workspace:*"
Expand Down Expand Up @@ -159,7 +152,7 @@
"test:unit": "yarn run build:lib && yarn test:watch --run",
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
"test": "npm-run-all lint test:locale-packs:unused test:unit test:companion",
"uploadcdn": "yarn node ./bin/upload-to-cdn.js",
"uploadcdn": "yarn node ./private/upload-to-cdn/index.js",
"version": "yarn node ./bin/after-version-bump.js",
"watch:css": "onchange 'packages/{@uppy/,}*/src/*.scss' --initial --verbose -- yarn run build:css",
"watch:js:bundle": "onchange 'packages/{@uppy/,}*/src/**/*.{js,ts,jsx,tsx}' --initial --verbose -- yarn run build:bundle",
Expand Down
4 changes: 2 additions & 2 deletions bin/upload-to-cdn.js → private/upload-to-cdn/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//
// Run as:
//
// npm run uploadcdn <package-name> [version]
// yarn uploadcdn <package-name> [version]
//
// To override an existing release (DANGER!)
//
// npm run uploadcdn <package-name> [version] -- --force
// yarn uploadcdn <package-name> [version] -- --force
//
// Authors:
//
Expand Down
12 changes: 12 additions & 0 deletions private/upload-to-cdn/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "upload-to-cdn",
"devDependencies": {
"@aws-sdk/client-s3": "^3.338.0",
"adm-zip": "^0.5.5",
"concat-stream": "^2.0.0",
"mime-types": "^2.1.26",
"npm-packlist": "^5.0.0",
"pacote": "^13.0.0",
"tar": "^6.1.0"
}
}
21 changes: 14 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8010,7 +8010,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@uppy-dev/build@workspace:."
dependencies:
"@aws-sdk/client-s3": "npm:^3.338.0"
"@babel/cli": "npm:^7.14.5"
"@babel/core": "npm:^7.14.6"
"@babel/eslint-parser": "npm:^7.11.3"
Expand All @@ -8028,11 +8027,9 @@ __metadata:
"@typescript-eslint/eslint-plugin": "npm:^7.0.0"
"@typescript-eslint/parser": "npm:^7.0.0"
"@uppy-dev/remark-lint-uppy": "workspace:*"
adm-zip: "npm:^0.5.5"
autoprefixer: "npm:^10.2.6"
babel-plugin-inline-package-json: "npm:^2.0.0"
chalk: "npm:^5.0.0"
concat-stream: "npm:^2.0.0"
cssnano: "npm:^7.0.0"
dotenv: "npm:^16.0.0"
esbuild: "npm:^0.21.2"
Expand All @@ -8058,11 +8055,8 @@ __metadata:
glob: "npm:^8.0.0"
jsdom: "npm:^24.0.0"
lint-staged: "npm:^15.0.0"
mime-types: "npm:^2.1.26"
npm-packlist: "npm:^5.0.0"
npm-run-all: "npm:^4.1.5"
onchange: "npm:^7.1.0"
pacote: "npm:^13.0.0"
postcss: "npm:^8.4.31"
postcss-dir-pseudo-class: "npm:^6.0.0"
postcss-logical: "npm:^5.0.0"
Expand All @@ -8076,7 +8070,6 @@ __metadata:
stylelint-config-rational-order: "npm:^0.1.2"
stylelint-config-standard: "npm:^36.0.0"
stylelint-config-standard-scss: "npm:^13.0.0"
tar: "npm:^6.1.0"
typescript: "npm:~5.4"
vitest: "npm:^1.2.1"
vue-template-compiler: "workspace:*"
Expand Down Expand Up @@ -29401,6 +29394,20 @@ __metadata:
languageName: node
linkType: hard

"upload-to-cdn@workspace:private/upload-to-cdn":
version: 0.0.0-use.local
resolution: "upload-to-cdn@workspace:private/upload-to-cdn"
dependencies:
"@aws-sdk/client-s3": "npm:^3.338.0"
adm-zip: "npm:^0.5.5"
concat-stream: "npm:^2.0.0"
mime-types: "npm:^2.1.26"
npm-packlist: "npm:^5.0.0"
pacote: "npm:^13.0.0"
tar: "npm:^6.1.0"
languageName: unknown
linkType: soft

"uppy@workspace:*, uppy@workspace:packages/uppy":
version: 0.0.0-use.local
resolution: "uppy@workspace:packages/uppy"
Expand Down

0 comments on commit efa993f

Please sign in to comment.