hello-theme/.github/workflows/publish-beta.yml
2021-12-20 08:11:45 +02:00

102 lines
3.7 KiB
YAML

name: Publish Beta Version
on: [workflow_dispatch]
jobs:
bump-version:
if: (github.actor == 'ronkelementor' || github.actor == 'KingYes') && startsWith(github.repository, 'elementor/')
runs-on: ubuntu-20.04
outputs:
prev_version: ${{ steps.bump_version_step.outputs.prev_version }}
steps:
- name: Checkout master branch
uses: actions/checkout@v2
with:
token: ${{ secrets.MAINTAIN_TOKEN }}
ref: master
- name: Get release branch
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/get-release-branch-name.sh"
- name: Checkout next release branch
uses: actions/checkout@v2
with:
token: ${{ secrets.MAINTAIN_TOKEN }}
ref: ${{ env.RELEASE_BRANCH }}
- name: Bump version
id: bump_version_step
run: |
npm install --no-package-lock --no-save semver@7.3.4
PREV_PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version")
NEW_PACKAGE_VERSION=$(node ./.github/scripts/update-prerelease-beta-version.js)
PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version")
if [[ $PACKAGE_VERSION == *beta1 ]]
then
PREV_PACKAGE_VERSION=$(node -p "require('./package.json').version")
fi
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "::set-output name=prev_version::${PREV_PACKAGE_VERSION}"
- name: Push new version to beta version to release branch
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }}
MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-bump.sh"
publish:
needs: bump-version
runs-on: ubuntu-16.04
steps:
- name: Checkout master branch
uses: actions/checkout@v2
with:
token: ${{ secrets.MAINTAIN_TOKEN }}
ref: master
- name: Get release branch
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/get-release-branch-name.sh"
- name: Checkout next release branch
uses: actions/checkout@v2
with:
token: ${{ secrets.MAINTAIN_TOKEN }}
ref: ${{ env.RELEASE_BRANCH }}
- name: Install Dependencies
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
npm ci
- name: Build
env:
VERSION: ${{ env.PACKAGE_VERSION }}
run: |
npm install --no-package-lock --no-save replace-in-file@6.2.0
node ./.github/scripts/update-version-in-files.js
npm config set git-tag-version false
npm version $VERSION
npm run zip
- name: Upload zip file to GitHub actions artifact
uses: actions/upload-artifact@v2
with:
name: hello-elementor.${{ env.PACKAGE_VERSION }}
path: hello-elementor.*.zip
if-no-files-found: error
- name: Create tag
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }}
MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/create-git-tag.sh"
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.PACKAGE_VERSION }}
files: hello-elementor.*.zip
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }}