From b8db38897cf5b1db9a69270e87122ad51db0cd95 Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Tue, 23 Apr 2024 20:13:33 +0530 Subject: [PATCH 1/8] Make changes related to release and deploy --- .github/workflows/deploy-dev.yml | 12 +++++++- .github/workflows/deploy.yml | 28 ++++++++++++++--- .github/workflows/release.yml | 32 ------------------- changlog.sh | 53 ++++++++++++++++++++++++++++++++ version.sh | 39 +++++++++++++++++++++++ 5 files changed, 126 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 changlog.sh create mode 100644 version.sh diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 81981dc6..d452beef 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -24,6 +24,16 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_READ_TOKEN }} + - name: Execute version.sh + run: | + chmod +x version.sh + ./version.sh + + - name: Execute changelog.sh + run: | + chmod +x changelog.sh + ./changelog.sh + - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -40,4 +50,4 @@ jobs: aws-region: ${{ secrets.S3_BUCKET_REGION }} - name: Deploy to S3 bucket - run: aws s3 sync ./dist s3://${{ secrets.S3_BUCKET }}/scripts/${{ github.event.repository.name }} --delete --cache-control max-age=0 + run: aws s3 sync ./dist s3://${{ secrets.S3_BUCKET }}/scripts/${{ github.event.repository.name }} --delete --cache-control max-age=0 \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 56566bea..d79ba058 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,8 +1,6 @@ -name: Deploy to WordPress.org +name: Deploy to WordPress.org and AWS S3 on: - release: - types: [published] - workflow_dispatch: + push: branches: - master jobs: @@ -13,6 +11,16 @@ jobs: - name: Checkout code uses: actions/checkout@master + - name: Execute version.sh + run: | + chmod +x version.sh + ./version.sh + + - name: Execute changelog.sh + run: | + chmod +x changelog.sh + ./changelog.sh + - name: Install dependencies run: yarn install --frozen-lockfile @@ -28,4 +36,14 @@ jobs: SVN_USERNAME: ${{ secrets.SVN_USERNAME }} SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SLUG: sesamy - BUILD_DIR: src \ No newline at end of file + BUILD_DIR: src + AWS_ACCESS_KEY_ID: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-1 + - name: Deploy latest to S3 bucket + run: aws s3 sync ./dist s3://sesamy-assets-cdn/scripts/${{ github.event.repository.name }} --delete --cache-control max-age=0 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1f6027a2..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Release -on: - release: - types: ['released'] - workflow_dispatch: - branches: - - master -jobs: - deploy: - runs-on: ubuntu-latest - env: - AWS_ACCESS_KEY_ID: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Build - run: yarn run build - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: eu-west-1 - - - name: Deploy latest to S3 bucket - run: aws s3 sync ./dist s3://sesamy-assets-cdn/scripts/${{ github.event.repository.name }} --delete --cache-control max-age=0 diff --git a/changlog.sh b/changlog.sh new file mode 100644 index 00000000..982cdb77 --- /dev/null +++ b/changlog.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +cd 'src' + +# Define the new version number (you can pass this as an argument or set it dynamically) +# Get the last created tag from GitHub +latest_tag=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') + +# Parse the tag into major, minor, and patch components +major=$(echo $latest_tag | cut -d. -f1) +minor=$(echo $latest_tag | cut -d. -f2) +patch=$(echo $latest_tag | cut -d. -f3) + +# Increment the patch version +((patch++)) + +# Get the last commit message +commit_message=$(git log -1 --pretty=%b) + +# Check if the commit message contains keywords and adjust version accordingly +if [[ $commit_message == *"major"* ]]; then + major=$((major + 1)) +elif [[ $commit_message == *"minor"* ]]; then + minor=$((minor + 1)) +elif [[ $commit_message == *"patch"* ]]; then + patch=$((patch + 1)) +fi + +# Construct the new version tag +new_version="$major.$minor.$patch" + +# Generate changelog +# Replace the command below with the actual command to generate the changelog +# Example: changelog-generator --version ${new_version} > changelog.txt + +# Update README.txt with new version and changelog +# Replace the placeholder with the actual path to your README.txt file +readme_file="README.txt" + +# Update stable version in readme.txt +sed -i "s/Stable tag: [0-9.]*/Stable tag: $new_version/" ${readme_file} + +# Get the last commit message +changelog_content=$(git log -1 --pretty=%b) + +# Remove major, minor, and patch keywords from the commit message +changelog_content=$(echo "$changelog_content" | sed 's/major//Ig; s/minor//Ig; s/patch//Ig') + +# Update changelog +sed -i "s/== Changelog ==/== Changelog ==\n\n= ${new_version} =\n* ${changelog_content}/" ${readme_file} + +echo "Version updated to ${new_version}" +echo "Changelog updated with content from last commit message : ${changelog_content}" \ No newline at end of file diff --git a/version.sh b/version.sh new file mode 100644 index 00000000..b997446c --- /dev/null +++ b/version.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +cd 'src' + +# Define the new version number (you can pass this as an argument or set it dynamically) +# Get the last created tag from GitHub +latest_tag=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') + +# Parse the tag into major, minor, and patch components +major=$(echo $latest_tag | cut -d. -f1) +minor=$(echo $latest_tag | cut -d. -f2) +patch=$(echo $latest_tag | cut -d. -f3) + +# Increment the patch version +((patch++)) + +# Get the last commit message +commit_message=$(git log -1 --pretty=%b) + +# Check if the commit message contains keywords and adjust version accordingly +if [[ $commit_message == *"major"* ]]; then + major=$((major + 1)) +elif [[ $commit_message == *"minor"* ]]; then + minor=$((minor + 1)) +elif [[ $commit_message == *"patch"* ]]; then + patch=$((patch + 1)) +fi + +# Construct the new version tag +new_version="$major.$minor.$patch" + +# Update version in sesamy.php +sed -i "s/define( 'SESAMY_VERSION', '[0-9.]*' );/define( 'SESAMY_VERSION', '$new_version' );/" sesamy.php + +# Update version in sesamy.php +sed -i "s/^\s*\*\s*Version:\s*[0-9.]*\s*$/ * Version: $new_version/" sesamy.php + +echo "Version updated to ${new_version}" + From 696886875016a831f0e05b6651f6ee33992a9e28 Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Wed, 24 Apr 2024 17:12:12 +0530 Subject: [PATCH 2/8] Modify package json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 503782e0..06fd433b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wordpress-sesamy", - "version": "1.5.1", + "version": "2.0.1", "description": "Dependencies for signature validation are implemented with libraries using composer.", "main": "index.js", "scripts": { From 69ff2e246d0eedb0e659c15f773db20f46507a60 Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Wed, 24 Apr 2024 17:22:45 +0530 Subject: [PATCH 3/8] Make change related to version in version and changelog file --- changlog.sh | 25 +------------------------ version.sh | 24 +----------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/changlog.sh b/changlog.sh index 982cdb77..cb09dc28 100644 --- a/changlog.sh +++ b/changlog.sh @@ -4,30 +4,7 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub -latest_tag=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') - -# Parse the tag into major, minor, and patch components -major=$(echo $latest_tag | cut -d. -f1) -minor=$(echo $latest_tag | cut -d. -f2) -patch=$(echo $latest_tag | cut -d. -f3) - -# Increment the patch version -((patch++)) - -# Get the last commit message -commit_message=$(git log -1 --pretty=%b) - -# Check if the commit message contains keywords and adjust version accordingly -if [[ $commit_message == *"major"* ]]; then - major=$((major + 1)) -elif [[ $commit_message == *"minor"* ]]; then - minor=$((minor + 1)) -elif [[ $commit_message == *"patch"* ]]; then - patch=$((patch + 1)) -fi - -# Construct the new version tag -new_version="$major.$minor.$patch" +new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') # Generate changelog # Replace the command below with the actual command to generate the changelog diff --git a/version.sh b/version.sh index b997446c..2b0ec796 100644 --- a/version.sh +++ b/version.sh @@ -4,30 +4,8 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub -latest_tag=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') +new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') -# Parse the tag into major, minor, and patch components -major=$(echo $latest_tag | cut -d. -f1) -minor=$(echo $latest_tag | cut -d. -f2) -patch=$(echo $latest_tag | cut -d. -f3) - -# Increment the patch version -((patch++)) - -# Get the last commit message -commit_message=$(git log -1 --pretty=%b) - -# Check if the commit message contains keywords and adjust version accordingly -if [[ $commit_message == *"major"* ]]; then - major=$((major + 1)) -elif [[ $commit_message == *"minor"* ]]; then - minor=$((minor + 1)) -elif [[ $commit_message == *"patch"* ]]; then - patch=$((patch + 1)) -fi - -# Construct the new version tag -new_version="$major.$minor.$patch" # Update version in sesamy.php sed -i "s/define( 'SESAMY_VERSION', '[0-9.]*' );/define( 'SESAMY_VERSION', '$new_version' );/" sesamy.php From a9fb09ac8b356109c5adcdfd9eebda788e296a4e Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Wed, 24 Apr 2024 19:35:27 +0530 Subject: [PATCH 4/8] Change deploy release --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d79ba058..ee7c2301 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,8 @@ name: Deploy to WordPress.org and AWS S3 on: - push: + release: + types: [published] + workflow_dispatch: branches: - master jobs: From 875457ea4dd18dc0bdb1c8f22276d898fb7ce242 Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Thu, 25 Apr 2024 15:29:09 +0530 Subject: [PATCH 5/8] Modify tag related changes and related files --- .github/workflows/deploy-dev.yml | 18 ++++++++++++++++++ .github/workflows/deploy.yml | 10 ---------- changlog.sh | 4 +++- version.sh | 5 +++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index d452beef..171d466d 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -23,6 +23,11 @@ jobs: run: yarn install --ignore-scripts env: NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_READ_TOKEN }} + + - name: Set up Git + run: | + git config --global user.email "julianidiart1987@hotmail.com" + git config --global user.name "Julián Idiart" - name: Execute version.sh run: | @@ -34,6 +39,19 @@ jobs: chmod +x changelog.sh ./changelog.sh + - name: Stage Changes + run: git add . + + - name: Commit Changes + run: | + git commit -m "chore(release): publish version in wordpress.org" + + - name: Push Changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ee7c2301..1c892be1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,16 +13,6 @@ jobs: - name: Checkout code uses: actions/checkout@master - - name: Execute version.sh - run: | - chmod +x version.sh - ./version.sh - - - name: Execute changelog.sh - run: | - chmod +x changelog.sh - ./changelog.sh - - name: Install dependencies run: yarn install --frozen-lockfile diff --git a/changlog.sh b/changlog.sh index cb09dc28..1fbe768c 100644 --- a/changlog.sh +++ b/changlog.sh @@ -4,7 +4,9 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub -new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') +#new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') +git fetch --depth=1 origin +refs/tags/*:refs/tags/* +new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) # Generate changelog # Replace the command below with the actual command to generate the changelog diff --git a/version.sh b/version.sh index 2b0ec796..4ff3a737 100644 --- a/version.sh +++ b/version.sh @@ -4,8 +4,9 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub -new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') - +#new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') +git fetch --depth=1 origin +refs/tags/*:refs/tags/* +new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) # Update version in sesamy.php sed -i "s/define( 'SESAMY_VERSION', '[0-9.]*' );/define( 'SESAMY_VERSION', '$new_version' );/" sesamy.php From ac3d1022b2c5119a2ab74ee4a4878c19dacb7e8d Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Thu, 25 Apr 2024 18:48:05 +0530 Subject: [PATCH 6/8] Add dynamic tag in commit massage --- .github/workflows/deploy-dev.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 171d466d..c62630ec 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -41,10 +41,20 @@ jobs: - name: Stage Changes run: git add . - + + - name: Fetch all tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Get latest semantic version tag + id: latest-tag + run: | + LATEST_TAG=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) + echo "Latest tag is $LATEST_TAG" + echo "::set-output name=tag::$LATEST_TAG" + - name: Commit Changes run: | - git commit -m "chore(release): publish version in wordpress.org" + git commit -m "chore(release): publish version ${{ steps.latest-tag.outputs.tag }} in wordpress.org" - name: Push Changes uses: ad-m/github-push-action@master From fa3ee5af190e170f387e3664cee9d8e7f356696a Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Fri, 26 Apr 2024 18:18:26 +0530 Subject: [PATCH 7/8] Change latest tag code in version and changelog --- .github/workflows/deploy-dev.yml | 44 ++++++++++++++++---------------- changlog.sh => changelog.sh | 6 ++--- version.sh | 5 ++-- 3 files changed, 28 insertions(+), 27 deletions(-) rename changlog.sh => changelog.sh (87%) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index c62630ec..64631dee 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -23,25 +23,20 @@ jobs: run: yarn install --ignore-scripts env: NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_READ_TOKEN }} - + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: yarn semantic-release + + - name: Build + run: yarn run build + - name: Set up Git run: | git config --global user.email "julianidiart1987@hotmail.com" git config --global user.name "Julián Idiart" - - name: Execute version.sh - run: | - chmod +x version.sh - ./version.sh - - - name: Execute changelog.sh - run: | - chmod +x changelog.sh - ./changelog.sh - - - name: Stage Changes - run: git add . - - name: Fetch all tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* @@ -51,6 +46,19 @@ jobs: LATEST_TAG=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) echo "Latest tag is $LATEST_TAG" echo "::set-output name=tag::$LATEST_TAG" + + - name: Execute version.sh + run: | + chmod +x version.sh + ./version.sh ${{ steps.latest-tag.outputs.tag }} + + - name: Execute changelog.sh + run: | + chmod +x changelog.sh + ./changelog.sh ${{ steps.latest-tag.outputs.tag }} + + - name: Stage Changes + run: git add . - name: Commit Changes run: | @@ -62,14 +70,6 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} branch: master - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: yarn semantic-release - - - name: Build - run: yarn run build - - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v2 with: diff --git a/changlog.sh b/changelog.sh similarity index 87% rename from changlog.sh rename to changelog.sh index 1fbe768c..2d819a87 100644 --- a/changlog.sh +++ b/changelog.sh @@ -5,9 +5,9 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub #new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') -git fetch --depth=1 origin +refs/tags/*:refs/tags/* -new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) - +#git fetch --depth=1 origin +refs/tags/*:refs/tags/* +#new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) +new_version=$1 # Generate changelog # Replace the command below with the actual command to generate the changelog # Example: changelog-generator --version ${new_version} > changelog.txt diff --git a/version.sh b/version.sh index 4ff3a737..25698de7 100644 --- a/version.sh +++ b/version.sh @@ -5,8 +5,9 @@ cd 'src' # Define the new version number (you can pass this as an argument or set it dynamically) # Get the last created tag from GitHub #new_version=$(curl -s "https://api.github.com/repos/sesamyab/wordpress-sesamy/tags" | jq -r '.[7].name') -git fetch --depth=1 origin +refs/tags/*:refs/tags/* -new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) +#git fetch --depth=1 origin +refs/tags/*:refs/tags/* +#new_version=$(git tag -l --sort=-v:refname | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -n 1) +new_version=$1 # Update version in sesamy.php sed -i "s/define( 'SESAMY_VERSION', '[0-9.]*' );/define( 'SESAMY_VERSION', '$new_version' );/" sesamy.php From c082386618dbf120e2a325e2ec2d3c0202976c3c Mon Sep 17 00:00:00 2001 From: PradeepWeb77 Date: Mon, 29 Apr 2024 13:48:36 +0530 Subject: [PATCH 8/8] feat: Make the semantic release work --- src/README.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/README.txt b/src/README.txt index bf6d25da..6e5c4574 100644 --- a/src/README.txt +++ b/src/README.txt @@ -4,7 +4,7 @@ Tags: sesamy, paywall Requires at least: 5.0.1 Requires PHP: 7.4 Tested up to: 6.4.2 -Stable tag: 2.0.1 +Stable tag: 2.0.5 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -102,6 +102,13 @@ The following filters can be used to modify the default output from the plugin: == Changelog == += 2.0.5 = +* Fix a duplicated preview in unlocked content with "Embed" lock mode + += 2.0.4 = +* Fix to display the content in "Public" access for "Event" and "Signed URL" lock modes +* Fix to hide the paywall if the content is public + = 2.0.1 = * Fixed show content if signed url not locked @@ -142,4 +149,4 @@ The following filters can be used to modify the default output from the plugin: * Adjustments and bugfixes = 1.0.0 = -* This is the first release of the plugin. +* This is the first release of the plugin. \ No newline at end of file