diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f36d7788 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +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: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '16' + - name: Release + run: | + chmod +x package.sh + 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: + 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..ae43b3cf 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" @@ -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/ @@ -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