Skip to content

Deploy / Create Release #59

Deploy / Create Release

Deploy / Create Release #59

name: 'Deploy / Create Release'
on:
milestone:
types: [ closed ]
env:
ARTIFACT_NAME: 'coblocks-plugin'
ARTIFACT_ZIP: 'coblocks.zip'
jobs:
update:
name: Update version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1
# Yarn is still required on this project, so we need to make sure it is
# installed globally.
- name: Install yarn
run: npm i -g yarn
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Validate tag version
run: |
MATCH='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'
if ! [[ $NEW_TAG_VERSION =~ $MATCH ]]; then
echo "::error::Milestone title does not match semver format: '$NEW_TAG_VERSION'"
exit 1
fi
- name: Update changelog.txt
run: |
echo -e "${{ github.event.milestone.title }} / $(date +%Y-%m-%d)\n===================\n${{ github.event.milestone.description }}\n\n$(cat changelog.txt)" > changelog.txt
- name: Install dependencies
run: |
composer install --no-interaction --no-progress --no-suggest --optimize-autoloader --prefer-dist
yarn install --immutable
- name: Run version update
run: npm --no-git-tag-version version $NEW_TAG_VERSION
- name: Push changes
run: |
git add -A .
git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify
git push
build:
name: Create artifact
uses: ./.github/workflows/deploy-create-artifact.yml
needs: update
tag:
runs-on: ubuntu-latest
name: Tag new version
needs: update
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Publish new tag
run: |
git tag $NEW_TAG_VERSION
git push origin $NEW_TAG_VERSION
release:
runs-on: ubuntu-latest
name: Create new release
needs: [ build, tag ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Set release version
run: |
echo "RELEASE_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $RELEASE_VERSION -n "${{ github.event.milestone.description }}" -t "$RELEASE_VERSION"
- name: Download plugin
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Upload asset to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload $RELEASE_VERSION ${{ env.ARTIFACT_ZIP }}
# deploy:
# name: Deploy to WordPress.org
# needs: [ build, tag ]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.repository.default_branch }}
# - name: Set version
# run: |
# echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
# - name: Download plugin
# uses: actions/download-artifact@v3
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: .artifacts
# - name: Unzip artifact
# run: |
# mkdir -p .wp-plugin-deploy
# unzip .artifacts/${{ env.ARTIFACT_ZIP }} -d .wp-plugin-deploy/
# mv .wp-plugin-deploy/coblocks .wp-plugin-deploy/coblocks-artifact
# - name: Deploy to WordPress.org
# uses: godaddy-wordpress/deploy-plugin-artifact@v1
# with:
# plugin-name: coblocks
# plugin-version: ${{ env.NEW_TAG_VERSION }}
# plugin-assets: ".wordpress-org"
# svn-username: "${{ secrets.GODADDY_WPORG_USERNAME }}"
# svn-password: "${{ secrets.GODADDY_WPORG_PASSWORD }}"