diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 17aa896..dfb6b2e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,12 +2,18 @@ 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: @@ -18,22 +24,34 @@ jobs: 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: jobs.check_for_release.outputs.version + if: needs.check_for_release.outputs.version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Check out the repo uses: actions/checkout@v3 - + + - 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 ${{ jobs.check_for_release.outputs.version }}" - git checkout - sed -i "s/version\":\ \"[0-9]\+\.\?[0-9]*\.\?[0-9]*/version\":\ \"${{ jobs.check_for_release.outputs.version }}/g" ./defo.txt - sed -i "s/Version:\ [0-9]\+\.\?[0-9]*\.\?[0-9]*/Version:\ ${{ jobs.check_for_release.outputs.version }}/g" ./pie.txt + 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" ./plugin.php + sed -i "s/\[Unreleased\]/\[${{ 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 . @@ -43,6 +61,6 @@ jobs: - name: Create a GitHub release uses: ncipollo/release-action@v1 with: - tag: ${{ jobs.check_for_release.outputs.version }} - name: ${{ jobs.check_for_release.outputs.version }} - body: ${{ jobs.check_for_release.outputs.version }} \ No newline at end of file + tag: ${{ needs.check_for_release.outputs.version }} + name: ${{ needs.check_for_release.outputs.version }} + body: ${{ needs.check_for_release.outputs.release_body }} diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..0322e4e --- /dev/null +++ b/changelog.md @@ -0,0 +1,21 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +### Added +- Some text to Coolfile + +## [6.0.0] 2022-09-29 +### Changed +- Removed text from coolfile + +## [5.1.1] 2022-09-29 + +### Added +- Initial functionality pre-changelog +- Adding a bit more +### Changed +- moved txt files to appropriately named files diff --git a/coolFile b/coolFile index 8f57830..a97aaef 100644 --- a/coolFile +++ b/coolFile @@ -1,3 +1 @@ -cool -really cool -really really really cool +fghijklmnop diff --git a/defo.txt b/package.json similarity index 96% rename from defo.txt rename to package.json index a26c91a..9e91cc3 100644 --- a/defo.txt +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ascott-analytical-chambers-test-standards", - "version": "5.0.0", + "version": "6.0.0", "main": "index.js", "repository": "git@bitbucket.org:pieweb/ascott-analytical-chambers-test-standards.git", "author": "Neil Pie ", diff --git a/pie.txt b/pie.txt deleted file mode 100644 index ac74ec9..0000000 --- a/pie.txt +++ /dev/null @@ -1,6 +0,0 @@ -hello - -Version: 5.0.0 -Or so it would seem - -Version: 1.0 diff --git a/plugin.php b/plugin.php new file mode 100644 index 0000000..babb6ea --- /dev/null +++ b/plugin.php @@ -0,0 +1,8 @@ +