Skip to content

Commit

Permalink
Merge pull request #36 from pie/release/next-release
Browse files Browse the repository at this point in the history
Release/next release
  • Loading branch information
Joseph-Worthington authored Dec 7, 2023
2 parents 75bc43c + 20a075f commit adb6681
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 75 deletions.
173 changes: 98 additions & 75 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,107 @@
name: Create a Release if required
name: Maybe Create a Release

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:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
dev: no
# 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:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
dev: no

- name: Get current date
id: get_date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- 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" ./${{ github.event.repository.name }}.php
sed -i "s/Version:\ [0-9]\+\.\?[0-9]*\.\?[0-9]*/Version:\ ${{ needs.check_for_release.outputs.version }}/g" ./${{ github.event.repository.name }}-mu.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
- name: Check for ignore file
id: check_files
uses: andstor/file-existence-action@v2
with:
files: ".zipignore"

- name: Get current date
id: get_date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- 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" ./${{ github.event.repository.name }}.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
- name: File exists
if: steps.check_files.outputs.files_exists == 'true'
shell: bash
# Only runs if all of the files exists
run: |
sed -i '/^[[:space:]]*$/d' .zipignore
sed 's/^/${{ github.event.repository.name }}\//' .zipignore > ../.zipignore
# This step creates a zip of the plugin which can be used for installation, and by the plugin updater.
- name: Build required zip artifact
run: |
cd ../
zip -r -q ~/${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }} -x ".git/*" ".github/*" "composer.*" "package.json" "update.json" "DOCKER_ENV" "docker_tag" "*.log"
- 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: "~/${{ github.event.repository.name }}.zip"
- name: File does not exist
if: steps.check_files.outputs.files_exists != 'true'
shell: bash
# Only runs if any of the files does not exist
run: |
touch ../.zipignore
# This step creates a zip of the plugin which can be used for installation, and by the plugin updater.
- name: Build required zip artifact
run: |
cd ../
zip -r -q ~/${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }} [email protected]
ls -la ~/
- 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: "~/${{ github.event.repository.name }}.zip"
8 changes: 8 additions & 0 deletions .zipignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/*
.github/*
composer.*
package.json
update.json
DOCKER_ENV
docker_tag
*.log
Binary file added assets/banners/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banners/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/icons/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
9 changes: 9 additions & 0 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
"name": "Pie Custom Functions",
"version": "1.1.0",
"download_url": "https://github.com/pie/pie-custom-functions/releases/download/1.1.0/pie-custom-functions.zip",
"banners": {
"low" : "./assets/banners/banner-772x225.png",
"high" : "./assets/banners/banner-1544x500.png"
},
"icons": {
"1x" : "./assets/icons/icon-128x128.png",
"2x" : "./assets/icons/icon-256x256.png",
"svg" : "./assets/icons/icon.svg"
},
"sections": {
"description" : "Custom functions for Pie Hosting"
}
Expand Down

0 comments on commit adb6681

Please sign in to comment.