added option for link to variable product #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
jobs: | |
# This job utilises a marketplace action tag to automatically create a release when a pull request | |
# is labelled as release:major, release:minor or release:patch (it can also be controlled via commit | |
# message - see their docs for more info) | |
# | |
# Unfortunately it doesn't expose a point at which we can change the files before the Version is | |
# tagged, so we run it in 'dry-run' mode and expose its outputs for use later if required | |
check_for_release: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.prerelease.outputs.version }} | |
release_body: ${{ steps.prerelease.outputs.body }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- id: prerelease | |
uses: rymndhng/release-on-push-action@master | |
name: Check if we are running a new release | |
with: | |
tag_prefix: "" | |
bump_version_scheme: norelease | |
dry_run: true | |
use_github_release_notes: true | |
# This job only runs if the previous job detects that a new release is required. It checks out the | |
# main branch of the repo, runs some string replaces via `sed` to bump the version numbers. These | |
# may be changed to suit your project if required. | |
# | |
# @TODO Investigate the possibility of adding a build step between Bump the Version Numbers and | |
# Create a Github Release. The release action allows for zip artifacts to be uploaded, which may | |
# be extremely appropriate for distribution. | |
create_release: | |
needs: check_for_release | |
runs-on: ubuntu-latest | |
if: needs.check_for_release.outputs.version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
# Pretty obvious what this does | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
# This action is used to install composer dependencies. | |
- name: Install Composer dependencies | |
uses: php-actions/composer@v6 | |
with: | |
dev: no | |
# This step is used to get the current date, which we are going to use in the changelog | |
- name: Get current date | |
id: get_date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
# This step runs through the files in the plugin and updates all of the relevant version numbers | |
# with the number of this release. It also updates the changelog with the current date and then | |
# commits the changes back to the main branch to the repo. | |
- name: Bump the version numbers | |
run: | | |
echo "Creating release version ${{ needs.check_for_release.outputs.version }}" | |
sed -i "s/version\":\ \"[0-9]\+\.\?[0-9]*\.\?[0-9]*/version\":\ \"${{ needs.check_for_release.outputs.version }}/g" ./package.json | |
sed -i "s/version\":\ \"[0-9]\+\.\?[0-9]*\.\?[0-9]*/version\":\ \"${{ needs.check_for_release.outputs.version }}/g" ./update.json | |
sed -i "s/download\/[0-9]\+\.\?[0-9]*\.\?[0-9]*/download\/${{ needs.check_for_release.outputs.version }}/g" ./update.json | |
sed -i "s/Version:\ [0-9]\+\.\?[0-9]*\.\?[0-9]*/Version:\ ${{ needs.check_for_release.outputs.version }}/g" ./plugin.php | |
sed -i "s/\[Unreleased\]/\[Unreleased\]\r\n\r\n## \[${{ needs.check_for_release.outputs.version }}\] ${{steps.get_date.outputs.date}} /g" ./changelog.md | |
git config user.name "Github Actions" | |
git config user.email "<>" | |
git add . | |
git commit -am "Version Numbering" | |
git push | |
# This step creates a zip of the plugin which can be used for installation, and then creates a zip | |
# of the plugin which can be used by the updater directory. These two need a different file structure | |
# so we create them separately. | |
- name: Build required zip artifacts | |
run: | | |
zip -r -q ~/woocommerce-waitlist-sober-compatibility.zip ./ -x ".git/*" ".github/*" "composer.*" "package.json" "update.json" "DOCKER_ENV" "docker_tag" "*.log" | |
# Finally we create a release in Github, and add the two zip files as artifacts. These can then be | |
# downloaded by users of the plugin. | |
- name: Create a GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ needs.check_for_release.outputs.version }} | |
name: ${{ needs.check_for_release.outputs.version }} | |
body: ${{ needs.check_for_release.outputs.release_body }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: "~/woocommerce-waitlist-sober-compatibility.zip,~/update.zip" |