From 3c8191654af9b85a3f7dc94797ce24243f015267 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 16 Sep 2024 21:57:11 +0000 Subject: [PATCH] feat: more release improvements --- docs/breaking-changes/v3.md | 2 ++ prerelease/README.md | 1 - prerelease/action.yaml | 38 +++++++++++++++++-------------------- release/README.md | 14 ++++++++++++++ release/action.yaml | 21 +++++++++++++------- 5 files changed, 47 insertions(+), 29 deletions(-) diff --git a/docs/breaking-changes/v3.md b/docs/breaking-changes/v3.md index 10c68ae..f61c624 100644 --- a/docs/breaking-changes/v3.md +++ b/docs/breaking-changes/v3.md @@ -3,3 +3,5 @@ The `go-version` input in the `release` and `prerelease` actions no longer exists. The action will use the installed version in the runner. + +The `push-docker-snapshot` input in the `prerelease` action no longer exists. Instead, set the `create-release` input to true. diff --git a/prerelease/README.md b/prerelease/README.md index b372e77..344b43d 100644 --- a/prerelease/README.md +++ b/prerelease/README.md @@ -18,7 +18,6 @@ GitHub Action that produces a new pre-release (snapshot) of a golang based repos | `checkout-fetch-depth` |

The number of commits to fetch. 0 indicates all history for all branches and tags

| `false` | `0` | | `create-prerelease` |

Whether semantic-release should create a prerelease or do a dry run. This can be useful to set to true when a prerelease requires pushing artifacts semantic-release is in charge of generating

| `false` | `false` | | `github-token` |

GitHub token that can checkout the consumer repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN'

| `true` | `""` | -| `push-docker-snapshot` |

If a docker snapshot image is generated, push it to the to the registry

| `false` | `false` | | `docker-username` |

Docker username to push the snapshot image to the registry

| `false` | `""` | | `docker-password` |

Docker password to push the snapshot image to the registry

| `false` | `""` | | `extra-plugins` |

Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. Defaults to install @open-turo/semantic-release-config.

| `false` | `@open-turo/semantic-release-config ` | diff --git a/prerelease/action.yaml b/prerelease/action.yaml index 7fe4c64..b61e95d 100644 --- a/prerelease/action.yaml +++ b/prerelease/action.yaml @@ -16,11 +16,6 @@ inputs: github-token: description: GitHub token that can checkout the consumer repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN' required: true - # TODO Could this be replaced by create-prerelease + the presence of the docker credentials? - push-docker-snapshot: - description: If a docker snapshot image is generated, push it to the to the registry - required: false - default: "false" docker-username: description: Docker username to push the snapshot image to the registry required: false @@ -133,6 +128,13 @@ runs: run: | echo "GOVERSION=$(< .go-version tr -d '\n')" >> $GITHUB_ENV + - name: Docker login + if: inputs.dockerhub-user != '' && inputs.dockerhub-password != '' && steps.prerelease.outputs.new-release-version != '' + uses: docker/login-action@v3 + with: + username: ${{ inputs.docker-username }} + password: ${{ inputs.docker-password }} + - name: Goreleaser uses: goreleaser/goreleaser-action@v6 env: @@ -140,22 +142,16 @@ runs: with: args: release - - name: Docker login - if: inputs.push-docker-snapshot == 'true' - uses: docker/login-action@v3 - with: - username: ${{ inputs.docker-username }} - password: ${{ inputs.docker-password }} - - name: Push Snapshot Image - if: inputs.push-docker-snapshot == 'true' - shell: bash - run: | - # Selects all the docker images that are not the latest tag. - # Maybe this doesn't cover all the cases and we could add an input to specify the tag format to push. - DOCKER_IMAGES=$(jq -r '.[] | select(.type == "Docker Image") | .path' dist/artifacts.json | grep -v ':latest') - for image in $DOCKER_IMAGES; do - docker push $image - done + # - name: Push Snapshot Image + # if: inputs.push-docker-snapshot == 'true' + # shell: bash + # run: | + # # Selects all the docker images that are not the latest tag. + # # Maybe this doesn't cover all the cases and we could add an input to specify the tag format to push. + # DOCKER_IMAGES=$(jq -r '.[] | select(.type == "Docker Image") | .path' dist/artifacts.json | grep -v ':latest') + # for image in $DOCKER_IMAGES; do + # docker push $image + # done - name: Add new version to summary shell: bash diff --git a/release/README.md b/release/README.md index 50fa79d..603022e 100644 --- a/release/README.md +++ b/release/README.md @@ -23,6 +23,8 @@ GitHub Action that produces a new Release of a golang based repository. | `github-token` |

GitHub token that can checkout the consumer repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN'

| `true` | `""` | | `dry-run` |

Whether to run semantic release in dry-run mode. It will override the dryRun attribute in your configuration file

| `false` | `false` | | `extra-plugins` |

Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. Defaults to install @open-turo/semantic-release-config.

| `false` | `@open-turo/semantic-release-config ` | +| `docker-username` |

Docker username to push the snapshot image to the registry

| `false` | `""` | +| `docker-password` |

Docker password to push the snapshot image to the registry

| `false` | `""` | ## Inputs @@ -92,6 +94,18 @@ This action is a `composite` action. # # Required: false # Default: @open-turo/semantic-release-config + + docker-username: + # Docker username to push the snapshot image to the registry + # + # Required: false + # Default: "" + + docker-password: + # Docker password to push the snapshot image to the registry + # + # Required: false + # Default: "" ``` diff --git a/release/action.yaml b/release/action.yaml index 01c5ec0..c9df253 100644 --- a/release/action.yaml +++ b/release/action.yaml @@ -21,6 +21,12 @@ inputs: description: Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. Defaults to install @open-turo/semantic-release-config. default: | @open-turo/semantic-release-config + docker-username: + description: Docker username to push the snapshot image to the registry + required: false + docker-password: + description: Docker password to push the snapshot image to the registry + required: false outputs: version: description: Version of the project @@ -62,13 +68,14 @@ runs: github-token: ${{ inputs.github-token }} env: GITHUB_TOKEN: ${{ inputs.github-token }} - # Since the release is created with semantic-release, we need to fetch the tags - # TODO Is this really needed - # - name: Fetch tags - # shell: bash - # run: | - # git fetch --tags - # git clean -fd + + - name: Docker login + uses: docker/login-action@v3 + if: inputs.dockerhub-user != '' && inputs.dockerhub-password != '' && steps.release.outputs.new-release-version != '' + with: + username: ${{ inputs.docker-username }} + password: ${{ inputs.docker-password }} + - name: Set args id: goreleaser-args shell: bash