diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml new file mode 100644 index 0000000..f4c38f8 --- /dev/null +++ b/.github/workflows/dev-release.yml @@ -0,0 +1,43 @@ +name: Dev Release + +on: + push: + branches: + - release-* + +jobs: + publish-s3: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install dependencies + run: npm ci + - name: Build the project + run: npm run build + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Deploy to S3 + run: sh -c scripts/deploy-staging.sh + + create-release: + needs: [publish-s3] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + generate_release_notes: true + name: Release ${{ github.ref_name }} + tag_name: ${{ github.ref_name }} + draft: false + prerelease: true diff --git a/.github/workflows/publish.yml b/.github/workflows/production-release.yml similarity index 51% rename from .github/workflows/publish.yml rename to .github/workflows/production-release.yml index 9efe841..0344ad1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/production-release.yml @@ -1,30 +1,24 @@ -name: Node.js Package - +name: Production Release on: push: branches: - main jobs: - build: + version-check: runs-on: ubuntu-latest outputs: version: ${{ steps.check.outputs.version }} changed: ${{ steps.check.outputs.changed }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm ci - - run: npm run build - name: Check version changes id: check uses: EndBug/version-check@v2 publish-github: - needs: build - if: needs.build.outputs.changed == 'true' + needs: version-check + if: needs.version-check.outputs.changed == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -36,15 +30,18 @@ jobs: node-version: 20 registry-url: https://npm.pkg.github.com/ scope: '@numbersprotocol' - - run: npm ci - - run: npm run build - - run: npm publish + - name: Install dependencies + run: npm ci + - name: Build the project + run: npm run build + - name: Deploy to GitHub Packages + run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-npm: - needs: build - if: needs.build.outputs.changed == 'true' + needs: version-check + if: needs.version-check.outputs.changed == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -53,13 +50,17 @@ jobs: node-version: 20 registry-url: 'https://registry.npmjs.org' scope: '@numbersprotocol' - - run: npm ci - - run: npm run build - - run: npm publish + - name: Install dependencies + run: npm ci + - name: Build the project + run: npm run build + - name: Deploy to NPM registry + run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} purge-cdn-cache: + needs: publish-npm runs-on: ubuntu-latest continue-on-error: true steps: @@ -67,25 +68,41 @@ jobs: run: | curl --fail-with-body -X GET "https://purge.jsdelivr.net/npm/@numbersprotocol/capture-eye@latest/dist/capture-eye.bundled.js" + publish-s3: + needs: version-check + if: needs.version-check.outputs.changed == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install dependencies + run: npm ci + - name: Build the project + run: npm run build + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Deploy to S3 + run: sh -c scripts/deploy-release.sh + create-release: - needs: [build, publish-github, publish-npm] + needs: [version-check, publish-github, publish-npm, publish-s3] runs-on: ubuntu-latest - if: needs.build.outputs.changed == 'true' + if: needs.version-check.outputs.changed == 'true' steps: - uses: actions/checkout@v4 - - name: Get changelog - id: changelog - run: | - echo "::set-output name=changes::$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:'%h %s')" - name: Create Release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ needs.build.outputs.version }} - release_name: Release ${{ needs.build.outputs.version }} - body: | - Changes: - ${{ steps.changelog.outputs.changes }} + name: Release ${{ needs.version-check.outputs.version }} + tag_name: ${{ needs.version-check.outputs.version }} + generate_release_notes: true draft: false prerelease: false diff --git a/README.md b/README.md index 7bdd0e4..9f29297 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,12 @@ It includes customizable action buttons for donations, purchases, or licensing,

-For more info on Capture Eye, refer to the GitBook [Captue Eye](https://docs.captureapp.xyz/capture-eye) page. +For more info on Capture Eye, refer to the GitBook [Capture Eye](https://docs.captureapp.xyz/capture-eye) page. ## Integration Please refer to the Capture Eye [Integration](https://docs.captureapp.xyz/capture-eye/installation-and-integration) GitBook page for detailed installation and usage guide. + +## Release + +For release process, please refer to [RELEASE.md](RELEASE.md). diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..e69de29 diff --git a/package-lock.json b/package-lock.json index 05a67c7..c212a8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@numbersprotocol/capture-eye", - "version": "1.5.1", + "version": "1.5.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@numbersprotocol/capture-eye", - "version": "1.5.1", + "version": "1.5.2", "license": "GPL-3.0", "dependencies": { "lit": "^3.0.0" diff --git a/package.json b/package.json index ac04f4c..6c087f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@numbersprotocol/capture-eye", - "version": "1.5.1", + "version": "1.5.2", "description": "Capture Eye widget seamlessly integrates into your website, facilitating secure and transparent provenance display and purchases of digital content directly from the creator", "main": "dist/capture-eye.js", "module": "dist/capture-eye.js", diff --git a/scripts/deploy-release.sh b/scripts/deploy-release.sh new file mode 100755 index 0000000..b59cba8 --- /dev/null +++ b/scripts/deploy-release.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Variables +DISTRIBUTION_ID="E1GEDS049Y53CA" +FILE_PATH="dist/capture-eye.bundled.js" +S3_BUCKET="numbers-static" + +# Define S3 keys for paths +LATEST_KEY="capture-eye/release/latest/capture-eye.bundled.js" +VERSION_KEY="capture-eye/release/$(npm pkg get version | tr -d \")/capture-eye.bundled.js" + +# CloudFront invalidation paths +INVALIDATION_PATHS="/$LATEST_KEY /$VERSION_KEY" + +echo "Invalidation paths: $INVALIDATION_PATHS" + +# Upload to S3 (latest version) +aws s3 cp $FILE_PATH s3://$S3_BUCKET/$LATEST_KEY +if [ $? -ne 0 ]; then + echo "Failed to upload $FILE_PATH to s3://$S3_BUCKET/$LATEST_KEY" + exit 1 +fi +echo "File uploaded to s3://$S3_BUCKET/$LATEST_KEY" + +# Upload to S3 (version-specific path) +aws s3 cp $FILE_PATH s3://$S3_BUCKET/$VERSION_KEY +if [ $? -ne 0 ]; then + echo "Failed to upload $FILE_PATH to s3://$S3_BUCKET/$VERSION_KEY" + exit 1 +fi +echo "File uploaded to s3://$S3_BUCKET/$VERSION_KEY" + +# Create the invalidation +INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths $INVALIDATION_PATHS --query 'Invalidation.Id' --output text) +if [ $? -ne 0 ]; then + echo "Failed to create invalidation" + exit 1 +fi +echo "Invalidation created with ID: $INVALIDATION_ID" + +# Function to check the status of the invalidation +check_invalidation_status() { + STATUS=$(aws cloudfront get-invalidation --distribution-id $DISTRIBUTION_ID --id $INVALIDATION_ID --query 'Invalidation.Status' --output text) + echo "Current status: $STATUS" +} + +# Loop until the invalidation status is "Completed" +while true; do + check_invalidation_status + if [ "$STATUS" = "Completed" ]; then + echo "success/done" + break + fi + # Wait for 5 seconds before checking again + sleep 5 +done