From 9ad6fe45403267e53c1943c268b44c2db0413a17 Mon Sep 17 00:00:00 2001 From: Mikael Arvola Date: Mon, 23 Sep 2024 15:48:49 -0500 Subject: [PATCH] Update workflows and builder template. --- .github/workflows/deploy.yml | 93 +++++++++++++++++++ .../workflows/deploy_development_manual.yml | 37 ++++++++ .../workflows/deploy_production_manual.yml | 5 +- .github/workflows/publish_npm.yml | 8 +- template/builder/{name}.json | 1 + template/package.json | 2 +- 6 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/deploy_development_manual.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..87b368c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,93 @@ +name: deploy +on: + release: + types: [published] +env: + MAJORVERSION: '' + MINORVERSION: '' + FULLVERSION: '' + PRERELEASE: '' + COMPONENT_NAME: ${{ github.event.repository.name }} +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v4 + - name: 'Get Version' + id: get_version + uses: dhkatz/get-version-action@v3.0.0 + + - name: 'Check for correct naming convention' + if: ${{ !steps.get_version.outputs.is-semver }} + run: exit 1 + - name: 'Get major version from tag' + run: echo "MAJORVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV + env: + GITHUB_BRANCH: ${{ steps.get_version.outputs.major }} + - name: 'Get minor version from tag' + run: echo "MINORVERSION=${GITHUB_BRANCH}.${GITHUB_BRANCH_MINOR}" >> $GITHUB_ENV + env: + GITHUB_BRANCH: ${{ steps.get_version.outputs.major }} + GITHUB_BRANCH_MINOR: ${{ steps.get_version.outputs.minor }} + - name: Get patch (full) version from tag + run: echo "FULLVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV + env: + GITHUB_BRANCH: ${{ steps.get_version.outputs.version-without-v }} + - name: Get prelease version from tag + run: echo "PRERELEASE=${GITHUB_BRANCH}" >> $GITHUB_ENV + env: + GITHUB_BRANCH: ${{ steps.get_version.outputs.prerelease }} + - name: Display major version install + run: echo "Installing major version ${MAJORVERSION} for ${COMPONENT_NAME}" + - name: Display minor version install + run: echo "Installing minor version ${MINORVERSION} for ${COMPONENT_NAME}" + - name: Display patch (full) version install + run: echo "Installing patch (full) version ${FULLVERSION} for ${COMPONENT_NAME}" + - name: Production run + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: echo "Running production deployment" + - name: Prerelease run + if: ${{ steps.get_version.outputs.prerelease != '' }} + run: echo "Running development deployment" + + - run: npm install + - run: npm rebuild + - run: npm run-script build + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }} + aws-region: us-east-2 + + - name: Deploy toolbox to S3 bucket for major version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MAJORVERSION --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache for major version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MAJORVERSION*" + - name: Deploy toolbox to S3 bucket for minor version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MINORVERSION --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache for minor version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MINORVERSION*" + - name: Deploy toolbox to S3 bucket for patch (full) version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache for patch (full) version + if: ${{ steps.get_version.outputs.prerelease == '' }} + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$FULLVERSION*" + - name: Deploy toolbox to S3 bucket for full version dev + if: ${{ steps.get_version.outputs.prerelease != '' }} + run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache for full version dev + if: ${{ steps.get_version.outputs.prerelease != '' }} + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$FULLVERSION*" + - name: Deploy toolbox to S3 bucket for latest dev + if: ${{ steps.get_version.outputs.prerelease != '' }} + run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/latest --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache for latest dev + if: ${{ steps.get_version.outputs.prerelease != '' }} + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/latest*" diff --git a/.github/workflows/deploy_development_manual.yml b/.github/workflows/deploy_development_manual.yml new file mode 100644 index 0000000..77e74ba --- /dev/null +++ b/.github/workflows/deploy_development_manual.yml @@ -0,0 +1,37 @@ +name: deploy_development_manual +on: + workflow_dispatch: + inputs: + version: + description: 'Version number' + required: true + default: '' + type: string +env: + COMPONENT_NAME: ${{ github.event.repository.name }} +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v4 + - name: Get version from input + run: echo "VERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV + env: + GITHUB_BRANCH: ${{ github.event.inputs.version }} + - name: Display version install + run: echo "Installing dev version ${VERSION} for component ${COMPONENT_NAME}" + + - run: npm install + - run: npm rebuild + - run: npm run-script build + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }} + aws-region: us-east-2 + - name: Deploy toolbox to S3 bucket + run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$VERSION --delete --acl bucket-owner-full-control + - name: Invalidate Cloudfront cache + run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$VERSION*" diff --git a/.github/workflows/deploy_production_manual.yml b/.github/workflows/deploy_production_manual.yml index 252cdca..d2eb320 100644 --- a/.github/workflows/deploy_production_manual.yml +++ b/.github/workflows/deploy_production_manual.yml @@ -8,9 +8,6 @@ on: default: '' type: string env: - MAJORVERSION: '' - MINORVERSION: '' - FULLVERSION: '' COMPONENT_NAME: ${{ github.event.repository.name }} jobs: build: @@ -23,7 +20,7 @@ jobs: env: GITHUB_BRANCH: ${{ github.event.inputs.version }} - name: Display version install - run: echo "Installing production version ${VERSION}" + run: echo "Installing production version ${VERSION} for component ${COMPONENT_NAME}" - run: npm install - run: npm rebuild diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml index 70d0cdf..964f0d0 100644 --- a/.github/workflows/publish_npm.yml +++ b/.github/workflows/publish_npm.yml @@ -1,8 +1,8 @@ name: publish_npm on: workflow_dispatch: - push: - tags: [ '**' ] + release: + types: [published] jobs: build: runs-on: ubuntu-latest @@ -15,7 +15,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: npm ci - - name: Publish to npm + - name: Install to npm run: npm publish --access public env: - NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}} + NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}} \ No newline at end of file diff --git a/template/builder/{name}.json b/template/builder/{name}.json index 04ac2a1..765f590 100644 --- a/template/builder/{name}.json +++ b/template/builder/{name}.json @@ -5,6 +5,7 @@ "type": "web component", "element-name": "<%= name %>", "description": "Description for builder.", + "purpose": "Imperative mood purpose for builder homepage.", "toolkit-version": "", "production-version": "", "development-version": "1.0.0-alpha" diff --git a/template/package.json b/template/package.json index 1be7c7d..dadef1a 100644 --- a/template/package.json +++ b/template/package.json @@ -29,6 +29,6 @@ "lit": "3.1.3" }, "devDependencies": { - "vite": "^5.2.0" + "vite": "^5.4.7" } } \ No newline at end of file