From 07d8adca8e3add7b6dd0c1fe2ba6dea9d8f8c7f1 Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Mon, 18 Mar 2024 11:48:52 -0300 Subject: [PATCH 1/4] chore: migrate travis ci to github actions --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ .travis.yml | 26 ----------------------- package.sh | 12 +++++------ scripts/deploy.sh | 8 +++---- 4 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..46aba31f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release +on: + release: + types: [created] + +jobs: + release: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + - name: Before Deploy + run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV + - name: Release + run: | + chmod +x package.sh + chmod +x scripts/deploy.sh + ./package.sh + ./scripts/deploy.sh + - name: Upload assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: | + transbank-webpay-plus-rest.zip + transbank-webpay-plus-rest-guzzle7.zip + asset_name: | + transbank-webpay-plus-rest.zip + transbank-webpay-plus-rest-guzzle7.zip + asset_content_type: application/zip diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index db0495a1..00000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php -php: - - '7.2' - - '7.3' -script: echo "We don't have tests yet :(" -before_deploy: - - sh package.sh -deploy: - - provider: releases - name: "$TRAVIS_TAG" - file: - - transbank-webpay-plus-rest.zip - - transbank-webpay-plus-rest-guzzle7.zip - api_key: $GITHUB_TOKEN - skip_cleanup: true - on: - repo: TransbankDevelopers/transbank-plugin-woocommerce-webpay-rest - tags: true - php: 7.3 - - provider: script - skip_cleanup: true - script: ./scripts/deploy.sh - on: - repo: TransbankDevelopers/transbank-plugin-woocommerce-webpay-rest - tags: true - php: 7.2 diff --git a/package.sh b/package.sh index d922b7b1..6e1fe123 100755 --- a/package.sh +++ b/package.sh @@ -1,11 +1,11 @@ #!/bin/sh #Script for create the plugin artifact -echo "Travis tag: $TRAVIS_TAG" +echo "Tag: $TAG" -if [ "$TRAVIS_TAG" = "" ] +if [ "$TAG" = "" ] then - TRAVIS_TAG='1.0.0' + TAG='1.0.0' fi SRC_DIR="plugin" @@ -29,8 +29,8 @@ else fi cd .. -sed -i.bkp "s/Version: VERSION_REPLACE_HERE/Version: ${TRAVIS_TAG#"v"}/g" "$SRC_DIR/$MAIN_FILE" -sed -i.bkp "s/VERSION_REPLACE_HERE/${TRAVIS_TAG#"v"}/g" "$SRC_DIR/$README_FILE" +sed -i.bkp "s/Version: VERSION_REPLACE_HERE/Version: ${TAG#"v"}/g" "$SRC_DIR/$MAIN_FILE" +sed -i.bkp "s/VERSION_REPLACE_HERE/${TAG#"v"}/g" "$SRC_DIR/$README_FILE" cp "$SRC_DIR/$COMPOSER_LOCK_FILE" "$SRC_DIR/$COMPOSER_LOCK_FILE.bkp" PLUGIN_FILE="transbank-webpay-plus-rest.zip" @@ -58,6 +58,6 @@ rm "$SRC_DIR/$MAIN_FILE.bkp" cp "$SRC_DIR/$README_FILE.bkp" "$SRC_DIR/$README_FILE" rm "$SRC_DIR/$README_FILE.bkp" -echo "Plugin version: $TRAVIS_TAG" +echo "Plugin version: $TAG" echo "Plugin file: $PLUGIN_FILE" echo "Plugin file Guzzle 7: $PLUGIN_FILE_GUZZLE" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index e259618c..9a6eea02 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -if [[ -z "$TRAVIS" ]]; then - echo "Script is only to be run by Travis CI" 1>&2 +if [[ -z "$GITHUB_ACTIONS" ]]; then + echo "Script is only to be run by GitHub Actions" 1>&2 exit 1 fi @@ -10,7 +10,7 @@ if [[ -z "$WP_ORG_PASSWORD" ]]; then exit 1 fi -if [[ -z "$TRAVIS_TAG" ]]; then +if [[ -z "$TAG" ]]; then echo "Build branch is required and must be a tag" 1>&2 exit 0 fi @@ -20,7 +20,7 @@ PLUGIN="transbank-webpay-plus-rest" PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" PLUGIN_BUILDS_PATH="$PROJECT_ROOT/builds" PLUGIN_BUILD_CONFIG_PATH="$PROJECT_ROOT/build-cfg" -VERSION=$TRAVIS_TAG +VERSION=$TAG ZIP_FILE="$PROJECT_ROOT/$PLUGIN.zip" # Ensure the zip file for the current version has been built From 301ec4926f9a0531b6e7c1e1b12bd18d2c9ca76d Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Mon, 18 Mar 2024 12:40:20 -0300 Subject: [PATCH 2/4] chore: add setup node to release workflow --- .github/workflows/release.yml | 4 ++++ package.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46aba31f..9ed9bd1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,10 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '7.4' + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '16' - name: Before Deploy run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV - name: Release diff --git a/package.sh b/package.sh index 6e1fe123..ae43b3cf 100755 --- a/package.sh +++ b/package.sh @@ -18,7 +18,7 @@ COMPOSER_LOCK_FILE="composer.lock" cd $SRC_DIR composer update composer install --no-dev -npm install +npm install --no-audit --no-fund --no-optional npm run build if [ $? -eq 0 ]; then rm -rf node_modules/ From b228b66bbd53489d09704f375c802f1f0f090ead Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Mon, 18 Mar 2024 13:00:28 -0300 Subject: [PATCH 3/4] chore: add env variables to release step --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ed9bd1b..e85482f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,9 @@ jobs: chmod +x scripts/deploy.sh ./package.sh ./scripts/deploy.sh + env: + WP_ORG_PASSWORD: ${{ secrets.WP_ORG_PASSWORD }} + TAG: ${{ github.event.release.tag_name }} - name: Upload assets uses: actions/upload-release-asset@v1 env: From db4d735962eb194c0a692e27dcff8f45b3edfd9f Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Mon, 18 Mar 2024 13:00:48 -0300 Subject: [PATCH 4/4] chore: remove Before Deploy step --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e85482f1..f36d7788 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: '16' - - name: Before Deploy - run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV - name: Release run: | chmod +x package.sh