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..0b343fd 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 @@ -128,45 +123,44 @@ runs: echo "version=${{ steps.prerelease.outputs.new-release-version }}" >> $GITHUB_OUTPUT echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "$GITHUB_OUTPUT" - - name: Set Go Version - shell: bash - run: | - echo "GOVERSION=$(< .go-version tr -d '\n')" >> $GITHUB_ENV + - name: Docker login + if: inputs.docker-username != '' && inputs.docker-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 + id: goreleaser env: GITHUB_TOKEN: ${{ inputs.github-token }} 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 if: steps.prerelease.outputs.new-release-published == 'true' env: NEW_VERSION: ${{ steps.vars.outputs.version }} - DOCKER_IMAGE: ${{ steps.build-docker.outputs.image-with-tag }} + GORELEASER_ARTIFACTS: ${{ steps.goreleaser.outputs.artifacts }} + GORELEASER_METADATA: ${{ steps.goreleaser.outputs.metadata }} run: | echo "::notice::new version: \`${NEW_VERSION}\`" echo "#### New version: \`${NEW_VERSION}\`" >> $GITHUB_STEP_SUMMARY - echo "#### Docker image: \`${DOCKER_IMAGE}\`" >> $GITHUB_STEP_SUMMARY + echo "#### Artifacts: \`${GORELEASER_ARTIFACTS}\`" >> $GITHUB_STEP_SUMMARY + echo "#### Metadata: \`${GORELEASER_METADATA}\`" >> $GITHUB_STEP_SUMMARY - name: Add no new version to summary shell: bash @@ -201,6 +195,7 @@ runs: ## Prerelease build **Build version:** `${{ steps.vars.outputs.version }}` - **Docker image:** `${{ steps.build-docker.outputs.image-with-tag }}` + **Artifacts:** `${{ steps.goreleaser.outputs.artifacts }}` + **Metadata:** `${{ steps.goreleaser.outputs.metadata }}` [Build output](${{ steps.vars.outputs.run-url }}) 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
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..efb5ed7 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.docker-user != '' && inputs.docker-password != '' && steps.release.outputs.new-release-version != '' + with: + username: ${{ inputs.docker-username }} + password: ${{ inputs.docker-password }} + - name: Set args id: goreleaser-args shell: bash @@ -81,7 +88,5 @@ runs: env: GITHUB_TOKEN: ${{ inputs.github-token }} GOPRIVATE: github.com/turo/ - # TODO Handle the prerelease value? How can we get this out of the semantic-release output? - # This is done in the goreleaser config file with the prerelease: auto option with: args: release ${{ steps.goreleaser-args.outputs.args }}