diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 81981dc6..64631dee 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -32,6 +32,44 @@ jobs: - 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: 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: 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: | + 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 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v2 with: @@ -40,4 +78,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..1c892be1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy to WordPress.org +name: Deploy to WordPress.org and AWS S3 on: release: types: [published] @@ -28,4 +28,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/changelog.sh b/changelog.sh new file mode 100644 index 00000000..2d819a87 --- /dev/null +++ b/changelog.sh @@ -0,0 +1,32 @@ +#!/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 +#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) +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 + +# 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/src/README.txt b/src/README.txt index 5c452927..6e5c4574 100644 --- a/src/README.txt +++ b/src/README.txt @@ -149,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 diff --git a/version.sh b/version.sh new file mode 100644 index 00000000..25698de7 --- /dev/null +++ b/version.sh @@ -0,0 +1,19 @@ +#!/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 +#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) +new_version=$1 + +# 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}" +