From 19813ec885e59957556f9c1ac07ca8a4e8f350fa Mon Sep 17 00:00:00 2001 From: Phillip Oldham Date: Sat, 30 Jan 2021 13:10:45 +0100 Subject: [PATCH] Add release workflow [changelog] added: github workflow to automate releases --- .github/workflows/ci.yml | 7 +-- .github/workflows/release.yml | 108 ++++++++++++++++++++++++++++++++++ README.md | 7 ++- 3 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e4ebe9..347296b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,6 @@ name: CI -on: - push: - # CI shouldn't need to run on the main branch, - # just working & PR branches - branches-ignore: - - main +on: push jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6c396a3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,108 @@ +name: Release + +on: + # Trigger this workflow on push (merge) events, + # but only for the main branch + push: + branches: + - main + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + +jobs: + release: + name: Create Release + runs-on: ubuntu-latest + + steps: + - name: "[Git] Checkout code" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "[Setup] Open /usr/local/bin Permissions" + run: sudo chmod -R a+rwx /usr/local/bin + + - name: "[Setup] Cache Dependencies" + id: cache + uses: actions/cache@v2 + with: + path: | + /usr/local/bin/git-cl + key: ${{ runner.os }}-release + restore-keys: | + ${{ runner.os }}-release + + - name: "[Version] Install" + uses: gittools/actions/gitversion/setup@v0.9.6 + with: + versionSpec: '5.x' + + - name: "[Version] Calculate" + id: gitversion # step id used as reference for output values + uses: gittools/actions/gitversion/execute@v0.9.6 + + - name: "[Version] Capture" + run: echo "RELEASE_VERSION=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_ENV + + - name: "[Version] Update" + run: | + sed -i 's/@version ".*"/@version "${{env.RELEASE_VERSION}}"/gi' mix.exs + + - name: "[Changelog] Create temporary tag for correct output" + uses: rickstaa/action-create-tag@v1 + with: + tag: ${{env.RELEASE_VERSION}} + message: "Tag for release ${{env.RELEASE_VERSION}}" + force_push_tag: true + + - name: "[Changelog] Install build tools" + uses: fwal/setup-swift@v1 + if: steps.cache.outputs.cache-hit != 'true' + with: + swift-version: "5.2" + + - name: "[Changelog] Install git-ci" + if: steps.cache.outputs.cache-hit != 'true' + run: | + cd /tmp/ + git clone https://github.com/uptech/git-cl.git git-cl + cd ./git-cl + make -j$(nproc) + sudo make install + sudo chmod a+rwx /usr/local/bin/git-cl + cd - + + - name: "[Changelog] Generate" + run: | + git cl full > CHANGELOG.md + sed -i 's/,.*$/./gi' CHANGELOG.md + + - name: "[Release] Commit release updates" + uses: EndBug/add-and-commit@v7 + with: + add: '["mix.exs", "CHANGELOG.md"]' + message: "Update CHANGELOG & version in preparation for release" + push: true + + - name: "[Release] Delete temporary tag" + uses: dev-drprasad/delete-tag-and-release@v0.1.2 + with: + delete_release: false + tag_name: ${{env.RELEASE_VERSION}} + + - name: "[Release] Create new release" + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{env.RELEASE_VERSION}} + release_name: ${{env.RELEASE_VERSION}} + body: | + Please see the CHANGELOG for further details + draft: false + prerelease: false + + - name: "[Release] Publish to Hex.pm" + uses: erlangpack/github-action@v1 diff --git a/README.md b/README.md index b90357c..ef200c4 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ The project is managed on a best-effort basis, and aims to be "good enough". If there are features missing please raise a ticket or create a Pull Request by following these steps: -1. [Fork it](/fork) +1. [Fork it][fork] 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) @@ -173,6 +173,7 @@ You may view the LICENSE in which this software is provided to you > has been advised of the possibility of such damages. [ci-badge]: https://github.com/OldhamMade/phoenix_sass/workflows/CI/badge.svg -[coverage-badge]: https://coveralls.io/repos/github/OldhamMade/phoenix_sass/badge.svg -[coverage-link]: https://coveralls.io/github/OldhamMade/phoenix_sass +[coverage-badge]: https://coveralls.io/repos/github/OldhamMade/phoenix_sass/badge.svg?branch=main +[coverage-link]: https://coveralls.io/github/OldhamMade/phoenix_sass?branch=main [sass_compiler_opts]: https://hexdocs.pm/sass_compiler/Sass.html#module-currently-supported-sass-options +[fork]: https://github.com/OldhamMade/phoenix_sass/fork