From 29f3e4a58508aca2329f11e449c69152af7ab389 Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Thu, 11 Jan 2024 21:04:30 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9B=AB=20mommy=20can=20now=20dispatch?= =?UTF-8?q?=20releases=20whenever~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 82 +++++++++++++++++++++++++--------------- .github/workflows/ci.yml | 2 +- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d5e1ffb..9b90b05 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,11 +1,12 @@ -name: CD +name: ๐Ÿšš deploy~ on: - # 'push' creates a real release - push: - branches: [ main ] - # 'workflow_dispatch' does a dry run of the workflow workflow_dispatch: + inputs: + dry_run: + description: 'Dry run' + type: boolean + default: true permissions: contents: write @@ -13,16 +14,33 @@ permissions: packages: read jobs: - check-release-needed: + pre-flight-checks: if: "!(contains(github.event.head_commit.message, '[cd skip]') || contains(github.event.head_commit.message, '[skip cd]'))" runs-on: ubuntu-latest + + outputs: + MOMMY_VERSION: ${{ steps.mommy_version.outputs.MOMMY_VERSION }} + steps: - - name: nop - run: true + - name: Checkout + uses: actions/checkout@v4 + - name: Extract mommy's version number + id: mommy_version + run: | + MOMMY_VERSION="v$(head -n 1 ./version)" + echo "MOMMY_VERSION=$MOMMY_VERSION" >> "$GITHUB_ENV" + echo "MOMMY_VERSION=$MOMMY_VERSION" >> "$GITHUB_OUTPUT" + - name: Check if release already exists + # yes, you really do need to compare with a string, and no, using ! does not work~ + if: ${{ github.event.inputs.dry_run == 'false' }} + # using `fetch-tags` option of `actions/checkout` does not work properly~ + run: | + git fetch --prune --unshallow --tags + ! git show-ref --tags "$MOMMY_VERSION" --quiet build-linux: - needs: [ check-release-needed ] + needs: [ pre-flight-checks ] runs-on: ubuntu-latest steps: - name: Checkout @@ -40,7 +58,7 @@ jobs: path: dist/mommy* build-macos: - needs: [ check-release-needed ] + needs: [ pre-flight-checks ] runs-on: macos-latest steps: - name: Checkout @@ -56,7 +74,7 @@ jobs: path: dist/mommy* build-freebsd: - needs: [ check-release-needed ] + needs: [ pre-flight-checks ] runs-on: ubuntu-latest steps: - name: Checkout @@ -99,7 +117,7 @@ jobs: path: dist/mommy* build-netbsd: - needs: [ check-release-needed ] + needs: [ pre-flight-checks ] runs-on: macos-12 steps: - name: Checkout @@ -137,7 +155,7 @@ jobs: path: dist/mommy* build-openbsd: - needs: [ check-release-needed ] + needs: [ pre-flight-checks ] runs-on: ubuntu-latest steps: - name: Checkout @@ -174,9 +192,12 @@ jobs: release-mommy: - needs: [ build-linux, build-macos, build-freebsd, build-netbsd, build-openbsd ] + needs: [ pre-flight-checks, build-linux, build-macos, build-freebsd, build-netbsd, build-openbsd ] runs-on: ubuntu-latest + env: + MOMMY_VERSION: ${{ needs.pre-flight-checks.outputs.MOMMY_VERSION }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -184,8 +205,6 @@ jobs: uses: actions/download-artifact@v3 with: name: dist - - name: Extract version number - run: echo "MOMMY_VERSION=v$(head -n 1 ./version)" >> $GITHUB_ENV - name: Extract release notes id: extract-release-notes uses: ffurrer2/extract-release-notes@v1 @@ -196,7 +215,7 @@ jobs: echo -e "mommy can also be installed using a package manager. [check the readme for more info](https://github.com/FWDekker/mommy/tree/${MOMMY_VERSION}#-installation)~\n" | cat - RELEASE_NOTES.md | tee RELEASE_NOTES.md - name: Checkout release uses: softprops/action-gh-release@v1 - if: github.event_name != 'workflow_dispatch' + if: ${{ github.event.inputs.dry_run == 'false' }} with: target_commitish: main tag_name: ${{ env.MOMMY_VERSION }} @@ -207,17 +226,17 @@ jobs: discussion_category_name: announcements release-apt: - needs: [ release-mommy ] + needs: [ pre-flight-checks, release-mommy ] runs-on: ubuntu-latest + env: + MOMMY_VERSION: ${{ needs.pre-flight-checks.outputs.MOMMY_VERSION }} + steps: - name: Checkout mommy uses: actions/checkout@v4 with: path: src-mommy - - name: Extract version number - run: echo "MOMMY_VERSION=v$(head -n 1 ./src-mommy/version)" >> $GITHUB_ENV - - name: Checkout apt-mommy uses: actions/checkout@v4 with: @@ -253,7 +272,7 @@ jobs: git commit -m "๐Ÿ”– mommy added package mommy $MOMMY_VERSION~" echo "::endgroup::" - if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then + if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then echo "::group::Push changes" git push origin echo "::endgroup::" @@ -263,10 +282,13 @@ jobs: fi; release-aur: - needs: [ release-mommy ] + needs: [ pre-flight-checks, release-mommy ] runs-on: ubuntu-latest container: archlinux:latest + env: + MOMMY_VERSION: ${{ needs.pre-flight-checks.outputs.MOMMY_VERSION }} + steps: - name: Set up basic system run: | @@ -287,8 +309,6 @@ jobs: uses: actions/checkout@v4 with: path: src-mommy - - name: Extract version number - run: echo "MOMMY_VERSION=v$(head -n 1 ./src-mommy/version)" >> $GITHUB_ENV - name: Checkout aur-mommy uses: actions/checkout@v4 @@ -326,7 +346,7 @@ jobs: sudo -u build git merge --commit master echo "::endgroup::" - if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then + if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then echo "::group::Push changes" sudo -u build git push origin master dev echo "::endgroup::" @@ -336,17 +356,17 @@ jobs: fi; release-homebrew: - needs: [ release-mommy ] + needs: [ pre-flight-checks, release-mommy ] runs-on: ubuntu-latest + env: + MOMMY_VERSION: ${{ needs.pre-flight-checks.outputs.MOMMY_VERSION }} + steps: - name: Checkout mommy uses: actions/checkout@v4 with: path: src-mommy - - name: Extract version number - run: echo "MOMMY_VERSION=v$(head -n 1 ./src-mommy/version)" >> $GITHUB_ENV - - name: Checkout homebrew-mommy uses: actions/checkout@v4 with: @@ -381,7 +401,7 @@ jobs: git merge --commit main echo "::endgroup::" - if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then + if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then echo "::group::Push changes" git push origin main dev echo "::endgroup::" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 223a252..11ce791 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: ๐Ÿงช ci~ on: push: From 0d3d5b61360fc21971b835f48c9a99d38a9d8138 Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Thu, 11 Jan 2024 21:14:02 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=80=20mommy=20updates=20docs=20abo?= =?UTF-8?q?ut=20the=20deploy=20action~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 3 ++- README.md | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11ce791..cc18f88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -429,7 +429,7 @@ jobs: test-netbsd: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -474,6 +474,7 @@ jobs: gmake test echo "::endgroup::" +# Extra tests disabled until https://github.com/vmactions/netbsd-vm/issues/4 is fixed # echo "::group::Build package" # gmake dist/netbsd # echo "::endgroup::" diff --git a/README.md b/README.md index aeeba25..c8888d6 100644 --- a/README.md +++ b/README.md @@ -742,12 +742,13 @@ users connect to the server, get the latest instructions, and their system build ### ๐Ÿ“ฏ release [`main`](https://github.com/FWDekker/mommy/tree/main) always contains the latest stable version. -every merge into `main` automatically build and releases a new version~ +to release a new version, just use the [deploy action](https://github.com/FWDekker/mommy/actions/workflows/cd.yml), +which can be activated using a `workflow_dispatch` event~
release checklists -* **before merging into `main`** +* **before triggering deployment** * update `version`~ * update all changelogs~ * update `CHANGELOG.md`~ @@ -761,7 +762,7 @@ every merge into `main` automatically build and releases a new version~ * update acknowledgements in `README.md`~ * update promotional images in `.github/img/`~ -* **after merging into `main`** +* **after triggering deployment** * a new github release is created automatically~ * [aur-mommy](https://github.com/FWDekker/aur-mommy/) * updated automatically when `mommy` updates From 535bf5b4b067dc5e50adc01ee727bdb5ad529250 Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Thu, 11 Jan 2024 21:25:49 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=96=A8=EF=B8=8F=20mommy=20prints=20di?= =?UTF-8?q?spatched=20inputs~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9b90b05..5804dcb 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -22,6 +22,9 @@ jobs: MOMMY_VERSION: ${{ steps.mommy_version.outputs.MOMMY_VERSION }} steps: + - name: Print inputs + run: | + echo "dry_run: ${{ github.event.inputs.dry_run }}" - name: Checkout uses: actions/checkout@v4 - name: Extract mommy's version number @@ -213,7 +216,7 @@ jobs: - name: Prepend release notes run: | echo -e "mommy can also be installed using a package manager. [check the readme for more info](https://github.com/FWDekker/mommy/tree/${MOMMY_VERSION}#-installation)~\n" | cat - RELEASE_NOTES.md | tee RELEASE_NOTES.md - - name: Checkout release + - name: Publish release uses: softprops/action-gh-release@v1 if: ${{ github.event.inputs.dry_run == 'false' }} with: