From e3e822fcc6ee057cb6a18380a19654f776794340 Mon Sep 17 00:00:00 2001 From: Dominic Watson Date: Mon, 27 Mar 2023 13:10:59 +0100 Subject: [PATCH] Convert to github actions --- .github/workflows/ci.yml | 96 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 20 --------- CHANGELOG.md | 4 ++ box.json | 4 +- buildDeployAndPublish.sh | 65 --------------------------- manifest.json | 2 +- 6 files changed, 103 insertions(+), 88 deletions(-) create mode 100755 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100755 buildDeployAndPublish.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100755 index 0000000..515256b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,96 @@ +name: Continuous Integration +on: + push: + pull_request: +jobs: + ci: + name: CI for Preside Calendar View extension + runs-on: ubuntu-latest + steps: + - name: Setup flow variables + run: | + branch=${GITHUB_REF##*/} + publish=false + if [[ "{{ env.event.name }}" != "pull_request" ]] ; then + if [[ $branch == release-* ]] || [[ $branch == v* ]] ; then + publish=true + fi + fi + echo "PUBLISH=$publish" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install dependencies + uses: pixl8/github-action-box-install@v2 + + - name: Generate release version number + if: "env.PUBLISH == 'true'" + id: versiongen + uses: pixl8/github-action-twgit-release-version-generator@v1 + + - name: Inject version into box json + if: "env.PUBLISH == 'true'" + uses: dominicwatson/github-action-envsubst@v1 + with: + files: box.json manifest.json + patterns: $VERSION_NUMBER + env: + VERSION_NUMBER: ${{ steps.versiongen.outputs.semver_release_string }} + + - name: Build static assets with grunt + if: "env.PUBLISH == 'true'" + shell: bash + run: | + cd assets && + npm install && + grunt && + rm -rf node_modules + + - name: Zip project + if: "env.PUBLISH == 'true'" + run: zip -rq $ZIP_FILE * -x jmimemagic.log -x .* -x *.sh -x *.log -x tests/**\* + shell: bash + env: + ZIP_FILE: ${{ steps.versiongen.outputs.semver_release_number }}.zip + + - name: Create Release + if: "env.PUBLISH == 'true'" + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.versiongen.outputs.semver_release_string }} + release_name: Release ${{ steps.versiongen.outputs.semver_release_string }} + draft: false + prerelease: ${{ steps.versiongen.outputs.semver_release_is_snapshot }} + + - name: Upload Release Asset + if: "env.PUBLISH == 'true'" + id: upload + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ${{ steps.versiongen.outputs.semver_release_number }}.zip + asset_name: ${{ steps.versiongen.outputs.semver_release_number }}.zip + asset_content_type: application/zip + + - name: Inject download location + if: "env.PUBLISH == 'true'" + uses: DominicWatson/github-action-envsubst@stable + with: + files: box.json + env: + DOWNLOAD_URL: ${{ steps.upload.outputs.browser_download_url }} + + - name: Publish to forgebox + if: "env.PUBLISH == 'true'" + uses: pixl8/github-action-box-publish@v3 + with: + forgebox_user: ${{ secrets.FORGEBOX_USER }} + forgebox_pass: ${{ secrets.FORGEBOX_PASS }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5103941..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: python -python: - - "3.5" -jdk: - - oraclejdk8 -node_js: - - "4.2.6" -cache: pip -before_install: - - mkdir /tmp/bin - - export PATH=$PATH:/tmp/bin -install: - - curl --location 'https://www.ortussolutions.com/parent/download/commandbox/type/bin' -o /tmp/box.zip - - unzip /tmp/box.zip -d /tmp/bin - - npm install grunt-cli -g - - pip install awscli -script: ./buildDeployAndPublish.sh - -notifications: - email: false \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0b701..a9f32ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.14 + +* Convert to github actions for publishing + ## 1.1.13 * [#15](https://github.com/pixl8/preside-ext-calendar-view/issues/15) Upgrade moment.js diff --git a/box.json b/box.json index 7f6a66c..ffc5b6c 100644 --- a/box.json +++ b/box.json @@ -1,8 +1,8 @@ { "name":"PresideCMS Extension: Calendar View", "type":"preside-extensions", - "version":"VERSION_NUMBER", - "location":"https://s3.eu-west-2.amazonaws.com/pixl8-public-packages/calendar-view/DOWNLOAD_LOCATION", + "version":"$VERSION_NUMBER", + "location":"$DOWNLOAD_URL", "private":false, "author":"Pixl8 Interactive", "directory":"application/extensions", diff --git a/buildDeployAndPublish.sh b/buildDeployAndPublish.sh deleted file mode 100755 index fb8d7d6..0000000 --- a/buildDeployAndPublish.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -if [[ $TRAVIS_TAG == v* ]] ; then - GIT_BRANCH=$TRAVIS_TAG - BRANCH_FOLDER=${GIT_BRANCH//origin\//} - BRANCH_FOLDER="${BRANCH_FOLDER##*/}" - ZIP_FILE=$BRANCH_FOLDER.zip - BUILD_DIR=build/ - PADDED_BUILD_NUMBER=`printf %05d $TRAVIS_BUILD_NUMBER` - - if [[ $GIT_BRANCH == v* ]] ; then - VERSION_NUMBER="${GIT_BRANCH//v}.$PADDED_BUILD_NUMBER" - else - VERSION_NUMBER="${GIT_BRANCH//release-}.$PADDED_BUILD_NUMBER-SNAPSHOT" - fi - - echo "Building Preside Extension: Calendar View" - echo "=========================================" - echo "GIT Branch : $GIT_BRANCH" - echo "Version number : $VERSION_NUMBER" - echo - - rm -rf $BUILD_DIR - mkdir -p $BUILD_DIR - - if [[ -d "assets" && -f "assets/Gruntfile.js" ]]; then - echo "Compiling static files..." - cd assets - npm install || exit 1 - grunt || exit 1 - echo "Done." - cd .. - fi - - echo "Copying files to $BUILD_DIR..." - rsync -a ./ --exclude=".*" --exclude="$BUILD_DIR" --exclude="*.sh" --exclude="**/node_modules" --exclude="*.log" --exclude="tests" "$BUILD_DIR" || exit 1 - echo "Done." - - cd $BUILD_DIR - echo "Inserting version number..." - sed -i "s/VERSION_NUMBER/$VERSION_NUMBER/" manifest.json - sed -i "s/VERSION_NUMBER/$VERSION_NUMBER/" box.json - sed -i "s/DOWNLOAD_LOCATION/$ZIP_FILE/" box.json - echo "Done." - - echo "Zipping up..." - zip -rq $ZIP_FILE * -x jmimemagic.log || exit 1 - mv $ZIP_FILE ../ - cd ../ - find ./*.zip -exec aws s3 cp {} s3://pixl8-public-packages/calendar-view/ --acl public-read \; - - cd $BUILD_DIR; - CWD="`pwd`"; - - box forgebox login username="$FORGEBOXUSER" password="$FORGEBOXPASS"; - box publish directory="$CWD"; - - cd ../ - - rm -rf $BRANCH_FOLDER -else - echo "Not publishing. This is not a tagged release."; -fi - -echo "Build complete :)" \ No newline at end of file diff --git a/manifest.json b/manifest.json index 4ccd627..6f30a06 100644 --- a/manifest.json +++ b/manifest.json @@ -2,5 +2,5 @@ "id" : "preside-ext-calendar-view" , "title" : "Calendar View" , "author" : "Pixl8 Interactive" - , "version" : "VERSION_NUMBER" + , "version" : "$VERSION_NUMBER" }