From adbc2622d7c18ad8b3d2563692948e73205a2f5b Mon Sep 17 00:00:00 2001 From: Agustin Tena Date: Sun, 28 Aug 2022 08:46:55 +0200 Subject: [PATCH] chore: rename and fix actions (#33) * rename deploy actions * rename and fix release action * remove period after version in footer --- .../{deploy_preview.yaml => ci-preview.yaml} | 2 +- .../{deploy_prod.yaml => ci-production.yaml} | 2 +- .github/workflows/ci-release.yaml | 54 +++++++++++++++++++ .github/workflows/release.yaml | 25 --------- pages/index.tsx | 2 +- 5 files changed, 57 insertions(+), 28 deletions(-) rename .github/workflows/{deploy_preview.yaml => ci-preview.yaml} (98%) rename .github/workflows/{deploy_prod.yaml => ci-production.yaml} (97%) create mode 100644 .github/workflows/ci-release.yaml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/deploy_preview.yaml b/.github/workflows/ci-preview.yaml similarity index 98% rename from .github/workflows/deploy_preview.yaml rename to .github/workflows/ci-preview.yaml index 1a16fe7..1d69d6f 100644 --- a/.github/workflows/deploy_preview.yaml +++ b/.github/workflows/ci-preview.yaml @@ -1,4 +1,4 @@ -name: Deploy preview +name: CI - Preview on: [pull_request] jobs: deploy: diff --git a/.github/workflows/deploy_prod.yaml b/.github/workflows/ci-production.yaml similarity index 97% rename from .github/workflows/deploy_prod.yaml rename to .github/workflows/ci-production.yaml index 3c6c4f1..6465f5e 100644 --- a/.github/workflows/deploy_prod.yaml +++ b/.github/workflows/ci-production.yaml @@ -1,4 +1,4 @@ -name: Deploy to production +name: CI - Production on: push: branches: diff --git a/.github/workflows/ci-release.yaml b/.github/workflows/ci-release.yaml new file mode 100644 index 0000000..ef2aba0 --- /dev/null +++ b/.github/workflows/ci-release.yaml @@ -0,0 +1,54 @@ +name: CI - Release +on: + push: + tags: + - v* +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + # if the action is a push, diff with the previous main commit + - name: Build changelog + id: build_changelog + run: | + echo "====== build changelog ======" + # create changelog file + echo "# What's Changed" > CHANGELOG.md + # check total app tags and the last commit tag + n_tags=`git tag -l 'v*' --sort=-v:refname | wc -l` + prev_tag=`git tag -l 'v*' --sort=-v:refname | sed '2q;d'` + if [ $n_tags -eq 1 ]; then + last_commit=`git rev-list --max-parents=0 HEAD` + else + last_commit=`git rev-list -n 1 $prev_tag` + fi + # fill changelog with commit descriptions + # set max tries equal to the maximum of commits as protection + max_tries=`git rev-list --count HEAD` + i=0 + while [ `git rev-parse HEAD~$i` != $last_commit ] && [ $i -lt $((max_tries-1)) ] + do + echo '- ' `git show -s --format=%s HEAD~$i` >> CHANGELOG.md + i=$((i+1)) + done + # set full changelog url + echo >> CHANGELOG.md + compare="" + if [ $n_tags -eq 1 ]; then + compare=$last_commit + else + compare=$prev_tag + fi + compare="${compare}...`git tag -l 'v*' --sort=-v:refname | sed '1q;d'`" + echo "**Full Changelog**: https://github.com/boxfish-studio/fontana/compare/${compare}" >> CHANGELOG.md + - name: Create Release + uses: actions/create-release@v1.1.2 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Fontana ${{ github.ref }} + draft: true + body_path: CHANGELOG.md diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index fab86d3..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Release -on: - push: - tags: - - v* -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Preparing release body - run: | - touch CHANGELOG.md - echo '### Changelog' >> CHANGELOG.md - echo '------' >> CHANGELOG.md - cat CHANGELOG.md - - name: Create Release - uses: actions/create-release@v1.1.2 - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Fontana ${{ github.ref }} - body_path: CHANGELOG.md diff --git a/pages/index.tsx b/pages/index.tsx index c2a40bc..a38c11c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -35,7 +35,7 @@ const Home: NextPage<{ HAS_MONGO_URI: boolean }> = ({ HAS_MONGO_URI }) => {