Code Monkey home page Code Monkey logo

release-on-push-action's Introduction

Github Release On Push Action

Stop using files for versioning. Use git tags instead!

Github Action to create a Github Release on pushes to master.

Features

  • Flexible version bumping scheme with a project default or overrides using Pull Request Labels
  • Creates Release Notes automatically (with a list of commits since the last release)

Rationale

CI & CD systems are simpler when they work with immutable monotonic identifers from the get-go. Trigger your release activites by subscribing to new tags pushed from this Action.

For automation, Github Releases (and by extension git tags) are better than versioned commit files for these reasons:

  • Agnostic of language & ecosystem (i.e. does not rely on presence of package.json)
  • Tagging does not require write permissions to bump version
  • Tagging does not trigger infinite-loop webhooks from pushing version bump commits

Example Workflow

on: 
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          bump_version_scheme: minor

Allowed values of bump_version_scheme:

  • minor
  • major
  • patch
  • norelease: Performs no release by default. Creation of release delegated to labels on Pull Requests.

For stability, we recommend pinning the version of the action. See Releases.

See action.yml for the full list of options.

FAQ

Can I skip creation of a release?

There are several approaches:

  1. Put [norelease] in the commit title.
  2. If the commit has an attached PR, add the label norelease to the PR.
  3. Set the action's bump_version_scheme to norelease to disable this behavior by default

How do I change the bump version scheme using Pull Requests?

Iif the PR has the label release:major, release:minor, or release:patch, this will override bump_version_scheme.

This repository's pull requests are an example of this in action. For example, #19.

Only one of these labels should be present on a PR. If there are multiple, the behavior is undefined.

Do I need to setup Github Action access tokens or any other permission-related thing?

Github Actions will inject a token for this plugin to interact with the API.

You need to specify the following permission scopes for this action to work correctly:

permissions:
  contents: write
  pull-requests: read

Alternatively, you can enable read and write permission to this token under settings > actions > general > workflow permissions (disabled by default), but beware that this provides all of the actions in your repository with read and write access to all scopes.

Can I create a tag instead of a release?

Currently, no.

In order to reliably generate monotonic versions, we use Github Releases to track what the last release version is. See Release#get-the-latest-release.

How can I get the generated tag or version?

On a successful release, this action creates an output parameters tag_name, upload_url and version.

Example of how to consume this:

on: 
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - id: release
        uses: rymndhng/release-on-push-action@master
        with:
          bump_version_scheme: minor
          tag_prefix: v
          
      - name: Check Output Parameters
        run: |
          echo "Got tag name ${{ steps.release.outputs.tag_name }}"
          echo "Got release version ${{ steps.release.outputs.version }}"
          echo "Upload release artifacts to ${{ steps.release.outputs.upload_url }}"

Can I customize the release body message?

Yes you can, with release_body. The contents of this be appended to the release description.

Example:

on:
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          bump_version_scheme: minor
          release_body: "When set, adds extra text to body!"

Can I use Github's Generated Release Notes?

Yes you can, by setting use-github-release-notes to true. For more information, see Automatic Release Notes.

Note, if enabling this feature:

  • If you have set release_body, the release_body will be prepended to the Generated Release Notes
  • Enabling this will disable the commit summary generated by this project

Example:

on:
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          bump_version_scheme: minor
          use_github_release_notes: true

Can I change the prefix v from the Git Tags?

Yes, you can customize this by changing the tag_prefix. Here's an example of removing the prefix by using an empty string.

on:
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          tag_prefix: ""

Can I change the name of the Release?

Yes, you can customize this by changing the release_name. The release_name supports these template variables:

  • <RELEASE_VERSION> contains the version number, i.e. 1.2.3
  • <RELEASE_TAG> contains the git tag name, i.e. v1.2.3

See example below for how to create a release with the name Release 1.2.3

on:
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          tag_prefix: "v"
          release_name: "Release <RELEASE_VERSION>"

How can I configure the maximum number of commits to summarize?

Use the option max_commits. The default value is 50.

on:
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          max_commits: 100

Development

Uses babashka

To run tests:

  1. Install babashka.
  2. Install direnv
  3. Create a .envrc file at the project root from this template:
export GITHUB_TOKEN=<YOUR_TOKEN>
export GITHUB_REPOSITORY=rymndhng/release-on-push-action
export GITHUB_SHA=167c690247d0933acde636d72352bcd67e33724b
export GITHUB_API_URL=https://api.github.com
export INPUT_BUMP_VERSION_SCHEME=minor
export INPUT_MAX_COMMITS=5
export INPUT_TAG_PREFIX=v
export INPUT_RELEASE_NAME="<RELEASE_TAG>"
export INPUT_DRY_RUN=1
  1. Run Tests
make test
make dryrun

Big Thanks To

release-on-push-action's People

Contributors

davidgregory084 avatar denisgarciafr avatar dmitriystoyanov avatar ethriel3695 avatar kaush-13 avatar mgaonach avatar mkorolyov avatar rymndhng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

release-on-push-action's Issues

Feature Request - Specify commit SHA as input

Hey guys,
our team is using this action to create a release of our main branch, as soon as the version has been successfully deployed to production.
This would mean e.g. that if deployment is stuck the releases get bigger etc. which is intended.

The problem we are facing is, that the production deployment is triggered from another repository, so when calling your action we always end up with all commits of the latest main branch in the release.
This can cause inconsistency when a new commit comes in while the production deployment is running.

If you could provide an option to optionally override the commit sha here with an input, we could scope the release to our needs:
https://github.com/rymndhng/release-on-push-action/blob/master/src/release_on_push_action/core.clj#L37

Thanks in advance!

Clean up integration tests

The tests have repeated environment setup & ceremony.

Tasks:

  • Move container tests into actual tests
  • Make assertions on the output body (or provide heuristics for a human eye to confirm the results)
    • is the "next tag" correct?
    • are commits limited correctly?
    • did the version bump semver correctly?

Add parameter to append to release body

It would be really great to append own message to body (e.g. if I run repository_dispatch I can pass some payload that will end up in body).

e.g

      uses: rymndhng/release-on-push-action@master
      with:
        bump_version_scheme: minor
        body: ${{ github.event.client_payload.message }}

Action bumps major version even though specified to create a release with patch bump.

When running the actions it was working fine previously but now it has been acting weird. It bumps major version creating releases like v2.0.0 , v3.0.0 and so on, even though I have specified to bump patch version. I also added release:patch label but that doesn't seem to work as well.

My Yml file

name: Development Release

on:
  workflow_dispatch:

jobs:
  release:
    name: ๐Ÿš€ Tag development release
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - name: Tag development release
        uses: rymndhng/release-on-push-action@master
        with:
          max_commits: 100
          bump_version_scheme: patch
          tag_prefix: 'dev-release-v'
          use_github_release_notes: true

Logs:

{:input/release-name <RELEASE_TAG>, :github/api-url https://api.github.com,/ :github/output /github/file_commands/set_output_2fba5ef1-29ea-4dfe-a66c-e7b04a0aec26, :bump-version-scheme patch, :input/tag-prefix dev-release-v, :input/max-commits 100, :token ***, :input/release-body , :input/use-github-release-notes true, :repo brite-live/brite-apis, :dry-run false, :sha 23b9ca19...300fef9cad6b6a}
Fetching related data...
Generating release...
Executing Release
 {
  "tag_name" : "dev-release-v2.0.0",
  "target_commitish" : "23b9ca...f9cad6b6a",
  "name" : "dev-release-v2.0.0",
  "body" : "Version 2.0.0\n\n",
  "draft" : false,
  "prerelease" : false,
  "generate_release_notes" : true
}

bug: new "steps.release.outputs.upload_url" is not working

The example from the readme is not working for the "upload_url":

on: 
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - id: release
        uses: rymndhng/release-on-push-action@master
        with:
          bump_version_scheme: minor
          tag_prefix: v
          
      - name: Check Output Parameters
        run: |
          echo "Got tag name ${{ steps.release.outputs.tag_name }}"
          echo "Got release version ${{ steps.release.outputs.version }}"
          echo "Upload release artifacts to ${{ steps.release.outputs.upload_url }}"

Result is:

Got tag name 0.0.1
Got release version 0.0.1
Upload release artifacts to 

I cannot see any test for the upload_url in the tests, so I would say this was broken anyway.

From the Output of the GitHub Action Log I can see that the upload_url is shown on the API Call.

The error should be on this line: https://github.com/rymndhng/release-on-push-action/blob/master/src/release_on_push_action/core.clj#L171

My assumption is that the prepare-key-value function is not good at escaping url's. I do not understand the clj language, so I'm not really able to debug or fix further. So please have a look ๐Ÿ˜€

Feature Request - configurable pr labels for version bump

Hey!

I'm experimenting with dependabot and this action. It would be awesome to configure the pr labels for the version bumps. Dependabot adds automatically major ,minor and patch labels to the pr and there is no way to change the labels name.

So instead of manually adding e.g. release:major while dependabot already added major I would like be able to configure the version bump pr labels.

Best

Use tag_prefix for selecting previous tag

I have a repository with releases being created on multiple branches. One branch is using a simple versioning scheme like v0.1.0 and another is using a prefix like other/v0.0.1.

I would like to use this action to generate the releases and have configured tag_prefix: other/v, which works great for naming the new releases. But, it has not used the tag_prefix to filter the previous releases. So it is creating a new release from v0.1.0...other/v0.1.1. Is there any way to have the previous release selector use the tag_prefix?

500 error on release with v0.25.0

I had this working just fine, but now suddenly the release api is returning a 500 error -- it's unclear to me where the problem is exactly... any suggestions or ideas about what's wrong here?

Fetching related data...
Generating release...
Executing Release
 {
  "tag_name" : "test-0.3.0",
  "target_commitish" : "92e6313338aac7c190879dde4c14dabebc75e999",
  "name" : "test-0.3.0",
  "body" : "Version 0.3.0\n\n",
  "draft" : false,
  "prerelease" : false,
  "generate_release_notes" : true
}
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  babashka.curl: status 500
Data:     {:status 500, :headers {"access-control-expose-headers" "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", "referrer-policy" "origin-when-cross-origin, strict-origin-when-cross-origin", "x-accepted-oauth-scopes" "repo", "server" "GitHub.com", "content-type" "application/json; charset=utf-8", "access-control-allow-origin" "*", "x-content-type-options" "nosniff", "content-length" "0", "x-frame-options" "deny", "strict-transport-security" "max-age=3[15](https://github.com/Chub-Engineering/sla-service/runs/7794009369?check_suite_focus=true#step:5:16)36000; includeSubdomains; preload", "x-ratelimit-limit" "5000", "x-ratelimit-remaining" "4939", "x-ratelimit-reset" "[16](https://github.com/***/repo-omitted/runs/7794009369?check_suite_focus=true#step:5:17)60246647", "x-github-request-id" "0506:8145:7BB5C3:14344B2:62F55379", "x-oauth-scopes" "repo, write:packages, write:repo_hook", "x-ratelimit-used" "61", "x-github-media-type" "github.v3; format=json", "date" "Thu, 11 Aug 2022 19:07:38 GMT", "vary" "Accept-Encoding, Accept, X-Requested-With", "x-ratelimit-resource" "core", "x-xss-protection" "0", "content-security-policy" "default-src 'none'"}, :body "", :err "", :process #object[java.lang.ProcessImpl 0xe06364c "Process[pid=29, exitValue=0]"], :exit 0}
Location: /var/src/release-on-push-action/src/release_on_push_action/core.clj:140:5

----- Context ------------------------------------------------------------------
136:   ;; Use a file because the release data may be too large for an inline curl arg
137:   (let [file (java.io.File/createTempFile "release" ".json")]
138:     (.deleteOnExit file)
139:     (json/encode-stream new-release-data (clojure.java.io/writer file))
140:     (curl/post (format "%s/repos/%s/releases" (:github/api-url context) (:repo context))
         ^--- babashka.curl: status 500
141:                {:body    file
142:                 :headers (github/headers context)})))
143: 
144: (defn set-output-escape
145:   "Escapes text for the set-output command in Github Actions.

----- Locals -------------------------------------------------------------------
context:          {:input/release-name "<RELEASE_TAG>", :github/api-url "https://api.github.com", :bump-version-scheme "minor", :input/tag-prefix "test-", :input/max-commits 50, :token "***", :input/release-body "", :input/use-github-release-notes true, :repo "***/repo-omitted", :dry-run false, ...}
new-release-data: {:tag_name "test-0.3.0", :target_commitish "92e6313338aac7c190879dde4c14dabebc75e999", :name "test-0.3.0", :body "Version 0.3.0\n\n", :draft false, :prerelease false, :generate_release_notes true}
file:             #object[java.io.File 0x686eabd0 "/tmp/release6467974715988198619.json"]

----- Stack trace --------------------------------------------------------------
babashka.curl/post                              - <built-in>
release-on-push-action.core/create-new-release! - /var/src/release-on-push-action/src/release_on_push_action/core.clj:140:5
release-on-push-action.core/create-new-release! - /var/src/release-on-push-action/src/release_on_push_action/core.clj:135:1
release-on-push-action.core                     - /var/src/release-on-push-action/src/release_on_push_action/core.clj:[18](https://github.com/***/repo-omitted/runs/7794009369?check_suite_focus=true#step:5:19)4:[20](https://github.com/***/repo-omitted/runs/7794009369?check_suite_focus=true#step:5:21)
clojure.core/println                            - <built-in>
release-on-push-action.core                     - /var/src/release-on-push-action/src/release_on_push_action/core.clj:184:11
clojure.core/apply                              - <built-in>
user                                            - <expr>:1:[52](https://github.com/***/repo-omitted/runs/7794009369?check_suite_focus=true#step:5:53)```

Can someone suggest what i'm missing ? - Error [ Message: For input string: ""]

Starting process...
Received context {:input/release-name Release <RELEASE_TAG>, :github/api-url https://api.github.com/, :github/output /github/file_commands/set_output_7dbf11af-bd06-4c78-87b2-ed0d35c1f59d, :bump-version-scheme minor, :input/tag-prefix ATOM_V, :input/max-commits 100, :token ***, :input/release-body , :input/use-github-release-notes false, :repo XXXXXXXX , :dry-run false, :sha d9eb89a531XXXXXXXXX9c2f7a454ad63[16](https://github.com/XXXXXXXXXXXX/actions/runs/6572617004/job/17854069715#step:3:17)c8e}
Fetching related data...
Generating release...
----- Error --------------------------------------------------------------------
Type:     java.lang.NumberFormatException
Message:  For input string: ""
Location: /var/src/release-on-push-action/src/release_on_push_action/core.clj:105:[29](https://github.com/XXXXXXXXXXX/actions/runs/6572617004/job/17854069715#step:3:30)

----- Context ------------------------------------------------------------------
101: 
102: (defn generate-new-release-data [context related-data]
103:   (let [bump-version-scheme (bump-version-scheme context related-data)
104:         current-version     (get-tagged-version (:latest-release related-data))
105:         next-version        (semver-bump current-version bump-version-scheme)
                                 ^--- For input string: ""
106:         base-commit         (get-in related-data [:latest-release-commit :sha])
107:         tag-name            (str (:input/tag-prefix context) next-version)
108: 
109:         ;; this is a lazy sequence
110:         commits-since-last-release (->> (github/list-commits-to-base context base-commit)

GitHub Actions: Deprecating save-state and set-output commands

Are getting warnings because of recent changes to Github Actions:

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Latest Tag Version errors with Type: clojure.lang.ExceptionInfo and Use a file because the release data may be too large for an inline curl arg

Greetings, here is the code for the githubaction run I had and here:

 - id: tag_release
        uses: rymndhng/[email protected]
        with:
          bump_version_scheme: minor
          tag_prefix: ""
          # temporary
          max_commits: 1

Here is the error:

Run rymndhng/[email protected]
  with:
    bump_version_scheme: minor
    max_commits: 1
  env:
    GITHUB_TOKEN: ***
    INCOMING_WEBHOOK_URL: ***
    PORT: 3001
    PROJECT_ID: ourcompany-907
/usr/bin/docker run --name b361ee218e2cfc8f74d1bad7e73660b905477_585ccd --label 7b361e --workdir /github/workspace --rm -e GITHUB_TOKEN -e INCOMING_WEBHOOK_URL -e PORT -e PROJECT_ID -e INPUT_BUMP_VERSION_SCHEME -e INPUT_TAG_PREFIX -e INPUT_MAX_COMMITS -e INPUT_RELEASE_BODY -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/ourrepo/ourrepo":"/github/workspace" 7b361e:e218e2cfc8f74d1bad7e73660b905477
Starting process...
Received context {:token ***, :repo ourcompany/ourrepo, :sha 0ebdc5b5388f6af146e59b57e34115127745eb00, :input/max-commits 1, :input/release-body , :input/tag-prefix , :bump-version-scheme minor, :dry-run false}
Fetching related data...
Generating release...
Executing Release
 {
  "tag_name" : "4.49.0",
  "target_commitish" : "0ebdc5b5388f6af146e59b57e34115127745eb00",
  "name" : "4.49.0",
  "body" : "Version 4.49.0\n\n\n### Commits\n\n- [0ebdc5b5] Update build.yml\n",
  "draft" : false,
  "prerelease" : false
}
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  babashka.curl: status 422
Location: /var/src/release-on-push-action/src/release_on_push_action/core.clj:119:5

----- Context ------------------------------------------------------------------
115:   ;; Use a file because the release data may be too large for an inline curl arg
116:   (let [file (java.io.File/createTempFile "release" ".json")]
117:     (.deleteOnExit file)
118:     (json/encode-stream new-release-data (clojure.java.io/writer file))
119:     (curl/post (format "https://api.github.com/repos/%s/releases" (:repo context))
         ^--- babashka.curl: status 422
120:                {:body    file
121:                 :headers {"Authorization" (str "token " (:token context))}})))
122: 
123: (defn set-output-escape
124:   "Escapes text for the set-output command in Github Actions.

----- Locals -------------------------------------------------------------------
context:          {:token "***", :repo "ourcompany/ourrepo", :sha "0ebdc5b5388f6af146e59b57e34115127745eb00", :input/max-commits 1, :input/release-body "", :input/tag-prefix "", :bump-version-scheme "minor", :dry-run false}
new-release-data: {:tag_name "4.49.0", :target_commitish "0ebdc5b5388f6af146e59b57e34115127745eb00", :name "4.49.0", :body "Version 4.49.0\n\n\n### Commits\n\n- [0ebdc5b5] Update build.yml\n", :draft false, :prerelease false}
file:             #object[java.io.File 0x6ff20b47 "/tmp/release12591324607771915577.json"]

----- Stack trace --------------------------------------------------------------
babashka.curl/post                              - <built-in>
release-on-push-action.core/create-new-release! - /var/src/release-on-push-action/src/release_on_push_action/core.clj:119:5
release-on-push-action.core/create-new-release! - /var/src/release-on-push-action/src/release_on_push_action/core.clj:114:1
release-on-push-action.core/apply               - /var/src/release-on-push-action/src/release_on_push_action/core.clj:163:20
release-on-push-action.core                     - /var/src/release-on-push-action/src/release_on_push_action/core.clj:163:11
/apply#if                                       - <expr>:156:8
                                                - <expr>:156:7
clojure.core/apply                              - <built-in>
user                                            - <expr>:1:52

I also attempted with master and it broke. Any assistance will be helpful as its it hindering us from building :( Thank you.

Allow the creation of releases based on an already existing version number

Use case

I have a branch dedicated to releases, and any PR's to this branch require that the version number of the project already be updated. As such, I do not need to make a bump when generating a release. I only need to create a release based on this number. As such the corresponding tag does not need a version bump. So it would be great if I could specify to this action that no version bump is required, but to still create a release and corresponding tag anyway.

Example:

  1. A PR is created to the dev branch, which contains a version bump from 1.6.0 to 1.7.0
  2. The PR gets merged to dev and a new PR gets opened from dev to stable
  3. The PR to stable gets merged
  4. This action gets run on the stable branch, creating a release with a tag of 1.7.0. (There is a prior step in this job that gets the version number from the file that contains it)

In the above example, setting bump_version_scheme to any of the existing options doesn't result in the desired behavior. norelease would cause no release to be published at all, and minor would result in a tag of 1.8.0, which isn't correct.

I hope I've described this issue clearly, please let me know if further explanation is required.

Exceeded a secondary rate limit

From now and then we are getting the following err only from release-on-push github action.

TLDR:

You have exceeded a secondary rate limit. Please wait a few minutes before you try again

Notice that this is not a regular rate limit which we did not exceeded, it is a secondary rate limit

Long output:

Run rymndhng/release-on-push-action@master
/usr/bin/docker run --name ead15a6d4926442e790af5ef18eb06db9_692e22 --label 72882e --workdir /github/workspace --rm -e GITHUB_TOKEN -e service_name -e INPUT_BUMP_VERSION_SCHEME -e INPUT_RELEASE_BODY -e INPUT_TAG_PREFIX -e INPUT_RELEASE_NAME -e INPUT_MAX_COMMITS -e INPUT_USE_GITHUB_RELEASE_NOTES -e INPUT_DRY_RUN -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true --network github_network_3bd28ad761fb454ab61a43d06657d8af -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_xxx_commands":"/github/xxx_commands" -v "/home/runner/work/xxx/xxx":"/github/workspace" 72882e:ad15a6d4926442e790af5ef18eb06db9
Starting process...
Received context {:input/release-name <RELEASE_TAG>, :github/api-url https://api.github.com, :bump-version-scheme patch, :input/tag-prefix v, :input/max-commits 50, :token ***, :input/release-body , :input/use-github-release-notes false, :repo xxx/xxx, :dry-run false, :sha xxx}
Fetching related data...
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  babashka.curl: status 403
Data:     {:status 403, :headers {"access-control-expose-headers" "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", "referrer-policy" "origin-when-cross-origin, strict-origin-when-cross-origin", "content-encoding" "gzip", "server" "GitHub.com", "content-type" "application/json; charset=utf-8", "access-control-allow-origin" "*", "x-content-type-options" "nosniff", "x-frame-options" "deny", "strict-transport-security" "max-age=31536000; includeSubdomains; preload", "x-ratelimit-limit" "30", "x-ratelimit-remaining" "30", "x-ratelimit-reset" "1655707052", "x-github-request-id" "0401:39CA:96AC5C:1AAAEC4:62B01570", "x-ratelimit-used" "1", "x-github-media-type" "github.v3; format=json", "date" "Mon, 20 Jun 2022 06:36:32 GMT", "vary" "Accept-Encoding, Accept, X-Requested-With", "x-ratelimit-resource" "search", "x-xss-protection" "0", "content-security-policy" "default-src 'none'"}, :body "{\n  \"documentation_url\": \"https://docs.github.com/en/free-pro-team@la***/rest/overview/resources-in-the-rest-api#secondary-rate-limits\",\n  \"message\": \"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.\"\n}\n", :err "", :process #object[java.lang.ProcessImpl 0xea01424 "Process[pid=13, exitValue=0]"], :exit 0}
Location: /var/src/release-on-push-action/src/release_on_push_action/github.clj:49:4
----- Context ------------------------------------------------------------------
45: (defn fetch-related-prs
46:   "See https://developer.github.com/v3/pulls/#list-pull-requests"
47:   [context]
48:   (parse-response
49:    (curl/get (format "%s/search/issues" (:github/api-url context))
       ^--- babashka.curl: status 403
50:              {:headers      (headers context)
51:               :query-params {"q" (format "repo:%s type:pr is:closed is:merged SHA:%s" (:repo context) (:sha context))}})))
52: 
53: ;; -- Github Releases API  -----------------------------------------------------
54: (defn fetch-la***-release
----- Locals -------------------------------------------------------------------
context: {:input/release-name "<RELEASE_TAG>", :github/api-url "https://api.github.com", :bump-version-scheme "patch", :input/tag-prefix "v", :input/max-commits 50, :token "***", :input/release-body "", :input/use-github-release-notes false, :repo "xxx/xxx", :dry-run false, ...}
----- Stack trace --------------------------------------------------------------
babashka.curl/get                               - <built-in>
release-on-push-action.github/parse-response    - /var/src/release-on-push-action/src/release_on_push_action/github.clj:49:4
release-on-push-action.github/parse-response    - /var/src/release-on-push-action/src/release_on_push_action/github.clj:22:1
release-on-push-action.github/fetch-related-prs - /var/src/release-on-push-action/src/release_on_push_action/github.clj:48:3
release-on-push-action.github/fetch-related-prs - /var/src/release-on-push-action/src/release_on_push_action/github.clj:45:1
release-on-push-action.core/fetch-related-data  - /var/src/release-on-push-action/src/release_on_push_action/core.clj:58:36
release-on-push-action.core/fetch-related-data  - /var/src/release-on-push-action/src/release_on_push_action/core.clj:56:1
release-on-push-action.core                     - /var/src/release-on-push-action/src/release_on_push_action/core.clj:170:22
clojure.core/apply                              - <built-in>
user                                            - <expr>:1:52

Error pushing with large number of commits

I'm trying this for the first time with a pending release with ~50 commits and it's failing with this error.

---- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  babashka.curl: status 422
Location: /var/src/release-on-push-action/src/release_on_push_action/core.clj:123:5

----- Context ------------------------------------------------------------------
119:   ;; Use a file because the release data may be too large for an inline curl arg
120:   (let [file (java.io.File/createTempFile "release" ".json")]
121:     (.deleteOnExit file)
122:     (json/encode-stream new-release-data (clojure.java.io/writer file))
123:     (curl/post (format "https://api.github.com/repos/%s/releases" (:repo context))
         ^--- babashka.curl: status 422
124:                {:body    file
125:                 :headers {"Authorization" (str "token " (:token context))}})))
126: 
127: (defn set-output-escape
128:   "Escapes text for the set-output command in Github Actions.

Aside from fixing the curl issue, it might be worth some option to shorten or even disable the release notes if they are beyond a certain size.

Otherwise, I'm really excited to switch over to this flow. I'm currently editing a different version file per project and it's a pain.

jq: error (at related_prs:7): Cannot iterate over null (null)

I created a job by copying the example into a new yaml file.

My logs:

2020-01-22T16:24:19.0277394Z ##[section]Starting: Request a runner to run this job
2020-01-22T16:24:19.0932909Z Requesting a hosted runner in current repository's account/organization with labels: 'ubuntu-latest', require runner match: True
2020-01-22T16:24:19.1433015Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-01-22T16:24:19.2160502Z ##[section]Finishing: Request a runner to run this job
2020-01-22T16:24:26.3765317Z Current runner version: '2.164.0'
2020-01-22T16:24:26.3766376Z Prepare workflow directory
2020-01-22T16:24:26.4006825Z Prepare all required actions
2020-01-22T16:24:26.4017507Z Download action repository 'rymndhng/release-on-push-action@master'
2020-01-22T16:24:27.8752730Z Build container for action use: '/home/runner/work/_actions/rymndhng/release-on-push-action/master/Dockerfile'.
2020-01-22T16:24:27.8830250Z ##[command]/usr/bin/docker build -t 488dfb:c487aab9e9ef4748ac1f3b77a2ca09f2 "/home/runner/work/_actions/rymndhng/release-on-push-action/master"
2020-01-22T16:24:28.8200934Z Sending build context to Docker daemon  19.46kB
2020-01-22T16:24:28.8201053Z 
2020-01-22T16:24:28.8203966Z Step 1/5 : FROM alpine:3.10
2020-01-22T16:24:28.8204312Z  ---> 965ea09ff2eb
2020-01-22T16:24:28.8204547Z Step 2/5 : RUN apk --no-cache add curl bash jq
2020-01-22T16:24:28.8205319Z  ---> Running in 0e12194e8b0c
2020-01-22T16:24:29.8073034Z fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
2020-01-22T16:24:29.8089774Z fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
2020-01-22T16:24:29.8561905Z (1/11) Installing ncurses-terminfo-base (6.1_p20190518-r0)
2020-01-22T16:24:29.8659615Z (2/11) Installing ncurses-terminfo (6.1_p20190518-r0)
2020-01-22T16:24:30.0590480Z (3/11) Installing ncurses-libs (6.1_p20190518-r0)
2020-01-22T16:24:30.0738558Z (4/11) Installing readline (8.0.0-r0)
2020-01-22T16:24:30.0872210Z (5/11) Installing bash (5.0.0-r0)
2020-01-22T16:24:30.1067217Z Executing bash-5.0.0-r0.post-install
2020-01-22T16:24:30.1092100Z (6/11) Installing ca-certificates (20190108-r0)
2020-01-22T16:24:30.1416752Z (7/11) Installing nghttp2-libs (1.39.2-r0)
2020-01-22T16:24:30.1515843Z (8/11) Installing libcurl (7.66.0-r0)
2020-01-22T16:24:30.1648283Z (9/11) Installing curl (7.66.0-r0)
2020-01-22T16:24:30.1757080Z (10/11) Installing oniguruma (6.9.4-r0)
2020-01-22T16:24:30.1895610Z (11/11) Installing jq (1.6-r0)
2020-01-22T16:24:30.2036535Z Executing busybox-1.30.1-r2.trigger
2020-01-22T16:24:30.2250972Z Executing ca-certificates-20190108-r0.trigger
2020-01-22T16:24:30.2705003Z OK: 17 MiB in 25 packages
2020-01-22T16:24:31.4975065Z Removing intermediate container 0e12194e8b0c
2020-01-22T16:24:31.5061003Z  ---> c1245095913e
2020-01-22T16:24:31.5062316Z Step 3/5 : COPY lib /lib
2020-01-22T16:24:32.0138628Z  ---> d9bffdfe0f21
2020-01-22T16:24:32.0139352Z Step 4/5 : COPY entrypoint.sh /entrypoint.sh
2020-01-22T16:24:33.0129630Z  ---> 387482633cc2
2020-01-22T16:24:33.0139919Z Step 5/5 : ENTRYPOINT [ "/entrypoint.sh" ]
2020-01-22T16:24:33.0317169Z  ---> Running in 5fe7ca65f1bf
2020-01-22T16:24:34.0196218Z Removing intermediate container 5fe7ca65f1bf
2020-01-22T16:24:34.0197505Z  ---> 95baba4f00bc
2020-01-22T16:24:34.0198361Z Successfully built 95baba4f00bc
2020-01-22T16:24:34.0341812Z Successfully tagged 488dfb:c487aab9e9ef4748ac1f3b77a2ca09f2
2020-01-22T16:24:34.0571125Z ##[group]Run rymndhng/release-on-push-action@master
2020-01-22T16:24:34.0571416Z with:
2020-01-22T16:24:34.0571558Z   strategy: minor
2020-01-22T16:24:34.0571699Z   bump_version_scheme: minor
2020-01-22T16:24:34.0571811Z env:
2020-01-22T16:24:34.0572423Z   GITHUB_TOKEN: ***
2020-01-22T16:24:34.0572607Z ##[endgroup]
2020-01-22T16:24:34.0801880Z ##[command]/usr/bin/docker run --name dfbc487aab9e9ef4748ac1f3b77a2ca09f2_6502b1 --label 488dfb --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_STRATEGY -e INPUT_BUMP_VERSION_SCHEME -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/python-tag-release-spike/python-tag-release-spike":"/github/workspace" 488dfb:c487aab9e9ef4748ac1f3b77a2ca09f2
2020-01-22T16:24:34.8461085Z jq: error (at related_prs:7): Cannot iterate over null (null)
2020-01-22T16:24:34.8873328Z jq: error (at related_prs:7): Cannot iterate over null (null)
2020-01-22T16:24:34.9323233Z jq: error (at related_prs:7): Cannot iterate over null (null)
2020-01-22T16:24:35.1607443Z ##[error]Docker run failed with exit code 1
2020-01-22T16:24:35.1624498Z Cleaning up orphan processes

my job:

on: 
  push:
    branches:
      - master

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          strategy: minor

Feature? Capture user in release

Hi,

Is there a way to record the user when creating the release via github actions, perhaps using the user who committed/pushed/created PR? This is currently being recorded as github-actions?

Thanks

The ability to add to the previous release doesn't seem to be working properly

Hello.

The current rymndhng/release-on-push-action is not working properly.

A release:major is set to a fixed release of 1.0.0.
A release:minor is set to a fixed release of 0.1.0.
A release:patch is set to a fixed release of 0.0.1.

For example, if you release release:minor twice, the first time will work fine, but
After the second time, the following errors will occur.

Starting process...
Received context {:bump-version-scheme norelease, :token ***, :repo ****/****, :dry-run false, :sha *********}
Fetching related data...
Generating release...
Executing Release
 {
  "name" : "0.1.0",
  "tag_name" : "v0.1.0",
  "draft" : false,
  "prerelease" : true,
  "target_commitish" : "*************",
  "body" : "**********"
}
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "Release",
      "code": "ready_exists",
      "field": "tag_name"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/repos/releases/#create-a-release"
}

The ability to add to the previous release doesn't seem to be working properly.

clojure.lang.ExceptionInfo: No matching ctor found for class java.lang.IllegalArgumentException [at line 66, column 22]

have been running into the error Generating release... clojure.lang.ExceptionInfo: No matching ctor found for class java.lang.IllegalArgumentException [at line 66, column 22] for the last couple of days; haven't updated our job(s) recently. The jobs look like:

name: Name

on:
  push:
    branches:
      - release

jobs:
  release-on-push:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: rymndhng/release-on-push-action@master
        with:
          strategy: minor

has anyone run into something like this before?

GitHub Organization Repository - HTTP 404

Hi,
I am getting 404, when i tried to use internally in my github organization. I created a Personal Access Token with read and write permission.
`
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: babashka.curl: status 404
Location: /var/src/release-on-push-action/src/release_on_push_action/github.clj:56:4

----- Context ------------------------------------------------------------------
52: (defn fetch-latest-release
53: "See https://developer.github.com/v3/repos/releases/#get-the-latest-release"
54: [context]
55: (parse-response
56: (curl/get
^--- babashka.curl: status 404
57: (format "https://api.github.com/repos/%s/releases/latest" (:repo context))
58: {:headers {"Authorization" (str "token " (:token context))}})))
`

Support for a `dry_run` input?

Hi, first of thanks for this Action, it's almost exactly what I need. There is one (hopefully simple) feature that I would benefit from - having access to the dry_run flag as a part of the action. Skimming the code it looks like it already exists for the tests. In our case, there are occasions when we want to generate the next tag first, but not actually create a release until a few other criteria have been fulfilled. Currently we have to use a couple different Actions to achieve this, but if this Action had a dry_run flag which still output the next tag/release without actually creating it then we could simplify our workflow.

Add output variable

Please consider adding an output variable of the new tag / version so subsequent actions can use it to, for example, upload release assets.

Support For Independent Semver Numbering For Different Branches

Hey @rymndhng @DmitriyStoyanov @ethriel3695 @denisgarciaglobal @lxwbr @

I am using this action for three different branches (dev, staging, and prod).

What I want to Implement:
I want to have each branch have its own semver numbering. I'm using the output to create tags for my docker images for each environment. dev branch semver number can be at v1.0.0, staging branch at v0.3.2 and prod branch at 0.2.1. The goal is to have each branch running each semver numbering independent of other branches

What the action is currently doing (Not desirable for my use case):
It is implementing a repository-wide increment. It a patch is done in the dev branch (where development is rapidly happening), It will affect the staging branch numbering by incrementing it anytime code gets merged into it, which also increment the prod branch subsequently. It makes tracking difficult for my images for each environment, represented by branches

How to calculate version, change files and then release in the same workflow?

I got a small problem. This action calculates the version while doing the release. Sadly I need the release version before so that I could edit some changelog files with that version number. So I tried:

      - name: Release-Version nur kalkulieren
        id: calculate_release_version
        uses: rymndhng/[email protected]
        env:
          GITHUB_TOKEN: ${{ env.TOKEN }}
        with:
          tag_prefix: ""
          bump_version_scheme: norelease

      - name: Check Output Parameters bevor Release erstellt wird
        run: |
          echo "Got tag name ${{ steps.calculate_release_version.outputs.tag_name }}"
          echo "Got release version ${{ steps.calculate_release_version.outputs.version }}"
          echo "Upload release artifacts to ${{ steps.calculate_release_version.outputs.upload_url }}"

      - name: Set release version in db changes - Does not matter how
      
      - name: Release erstellen
        id: create_release
        uses: rymndhng/[email protected]
        env:
          GITHUB_TOKEN: ${{ env.TOKEN }}
        with:
          tag_prefix: ""
          bump_version_scheme: patch
          use_github_release_notes: true
          release_body: "When set, adds extra text to body!"

      - name: Check Output Parameters nach Release Erstellung
        run: |
          echo "Got tag name ${{ steps.create_release.outputs.tag_name }}"
          echo "Got release version ${{ steps.create_release.outputs.version }}"
          echo "Upload release artifacts to ${{ steps.create_release.outputs.upload_url }}"

Sadly if the pull-request has any label with release:patch, release:minor, release:major set, then the "bump_version_scheme: norelease" gets overwritten as stated on the readme. Any idea on how to only calculate the version with this? I could do it with adding another action, but this one is so cool, that I do not really want to.

Used in Github Enterprise Server

I use this Github Action in Github Enterprise Server, but the API url seems to be a fixed value https://api.github.com/.
It will cause the response to be 401 when request to Github.
Can it be replace with a environment variable or else?

Feature Request: allow removing the "v".

Thanks for this project! I'm trying to use it with an existing project that already has a naming convention that doesn't include "v" at in the version or tag number. If this could be a true/false flag, or perhaps even an option to use a custom string, I think that would be a nice improvement, and help adoption of the tool.

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.