diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100755 index 9f0de3f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: humanmade/ci-php:7.3-node - - branches: - only: - # Whitelist branches to build for. - - master - steps: - # Checkout repo & subs: - - checkout - - # Get npm cache: - - restore_cache: - key: npm - - # Build steps: - - run: npm install --production - - run: npm run build - - # Make fast: - - save_cache: - key: npm - paths: - - ~/.npm - - # Run the deploy: - - deploy: - command: .circleci/deploy.sh diff --git a/.circleci/deploy-exclude.txt b/.circleci/deploy-exclude.txt deleted file mode 100755 index f31138d..0000000 --- a/.circleci/deploy-exclude.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Add files or patterns to exclude from the built branch here. -# Consult the "INCLUDE/EXCLUDE PATTERN RULES" section of the rsync manual for -# supported patterns. -# -# Note: Excluding ".circleci" will cause your branch to fail. Use the -# `branches` option in config.yml instead. - -.git -.gitignore -node_modules -package.json -package-lock.json diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh deleted file mode 100755 index 9be9d6f..0000000 --- a/.circleci/deploy.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -e -# -# Deploy your branch. -# - -DEPLOY_SUFFIX="${DEPLOY_SUFFIX:--built}" -GIT_USER="${DEPLOY_GIT_USER:-CircleCI}" -GIT_EMAIL="${DEPLOY_GIT_EMAIL:-hello@humanmade.com}" - -BRANCH="${CIRCLE_BRANCH}" -SRC_DIR="$PWD" -BUILD_DIR="/tmp/hm-build" - -if [[ -z "$BRANCH" ]]; then - echo "No branch specified!" - exit 1 -fi - -if [[ -d "$BUILD_DIR" ]]; then - echo "WARNING: ${BUILD_DIR} already exists. You may have accidentally cached this" - echo "directory. This will cause issues with deploying." - exit 1 -fi - -COMMIT=$(git rev-parse HEAD) -VERSION=$(grep 'Version: ' plugin.php | grep -oEi '[0-9\.a-z\+-]+$') - -if [[ $VERSION != "null" ]]; then - DEPLOY_BRANCH="${VERSION}--branch" - DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-yes}" -else - DEPLOY_BRANCH="${BRANCH}${DEPLOY_SUFFIX}" - DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-no}" -fi - -echo "Deploying $BRANCH to $DEPLOY_BRANCH" - -# If the deploy branch doesn't already exist, create it from the empty root. -if ! git rev-parse --verify "remotes/origin/$DEPLOY_BRANCH" >/dev/null 2>&1; then - echo -e "\nCreating $DEPLOY_BRANCH..." - git worktree add --detach "$BUILD_DIR" - cd "$BUILD_DIR" - git checkout --orphan "$DEPLOY_BRANCH" -else - echo "Using existing $DEPLOY_BRANCH" - git worktree add --detach "$BUILD_DIR" "remotes/origin/$DEPLOY_BRANCH" - cd "$BUILD_DIR" - git checkout "$DEPLOY_BRANCH" -fi - -# Ensure we're in the right dir -cd "$BUILD_DIR" - -# Remove existing files -git rm -rfq . - -# Sync built files -echo -e "\nSyncing files..." -if ! command -v 'rsync'; then - sudo apt-get install -q -y rsync -fi - -rsync -av "$SRC_DIR/" "$BUILD_DIR" --exclude-from "$SRC_DIR/.circleci/deploy-exclude.txt" - -# Add changed files -git add . - -if [ -z "$(git status --porcelain)" ]; then - echo "No changes to built files." - exit -fi - -# Print status! -echo -e "\nSynced files. Changed:" -git status -s - -# Double-check our user/email config -if ! git config user.email; then - git config user.name "$GIT_USER" - git config user.email "$GIT_EMAIL" -fi - -# Commit it. -MESSAGE=$( printf 'Build changes from %s\n\n%s' "${COMMIT}" "${CIRCLE_BUILD_URL}" ) -git commit -m "$MESSAGE" - -# Push it (real good). -git push origin "$DEPLOY_BRANCH" - -# Make a release if one doesn't exist. -if [[ $DEPLOY_AS_RELEASE = "yes" && $(git tag -l "$VERSION") != $VERSION ]]; then - git tag "$VERSION" - git push origin "$VERSION" -fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c9fe071 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +on: + push: + tags: + - '*' + +name: Create Release + +jobs: + release: + name: Create Release + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v2 + with: + node-version: '12' + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Create Release + uses: technote-space/release-github-actions@v7 + with: + CLEAN_TEST_TAG: true + CLEAN_TARGETS: .[!.]*,__tests__,package.json,yarn.lock,node_modules,tests,*.xml.dist + COMMIT_MESSAGE: "Built release for ${{ steps.get_version.outputs.VERSION }}. For a full change log look at the notes within the original/${{ steps.get_version.outputs.VERSION }} release." + CREATE_MAJOR_VERSION_TAG: false + CREATE_MINOR_VERSION_TAG: false + CREATE_PATCH_VERSION_TAG: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORIGINAL_TAG_PREFIX: original/ + OUTPUT_BUILD_INFO_FILENAME: build.json + TEST_TAG_PREFIX: test/