Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make changes related to release and deploy #108

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
40 changes: 39 additions & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
14 changes: 12 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to WordPress.org
name: Deploy to WordPress.org and AWS S3
on:
release:
types: [published]
Expand Down Expand Up @@ -28,4 +28,14 @@ jobs:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: sesamy
BUILD_DIR: src
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
32 changes: 0 additions & 32 deletions .github/workflows/release.yml

This file was deleted.

32 changes: 32 additions & 0 deletions changelog.sh
Original file line number Diff line number Diff line change
@@ -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}"
2 changes: 1 addition & 1 deletion src/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
19 changes: 19 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -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}"