Giter Site home page Giter Site logo

jimschubert / query-tag-action Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 13.0 24 KB

A GitHub Action allowing users to query tags via git describe.

Home Page: https://github.com/marketplace/actions/query-tag

License: Apache License 2.0

JavaScript 100.00%
github-actions hacktoberfest

query-tag-action's Introduction

query-tag-action

A GitHub Action allowing users to query tags via git describe --tags.

This is useful, for example, if you want to generate a changelog from your last release tag to your newest. Rather than apply that logic to multiple changelog tools, this action will set an output parameter to the last found tag. You should then be able to use that parameter in any changelog utility you'd like.

This action acts as a wrapper around git describe --tags, performing an unshallow operation on the git repository by default.

The actions/checkout@v2 action will check out a shallow repository. Although that action's readme documents how to unshallow, many users will never read that readme. For those savvy users who are already performing an unshallow, you may skip that operation in this action by passing the input skip-unshallow: "true".

Inputs

include

Optional Glob pattern of tags to include

The include option is passed to the git describe --match option. It is renamed in this action to complement exclude because I felt that include/exclude made more sense than match/exclude (Sorry, Linus).

exclude

Optional Glob pattern of tags to exclude

The exclude pattern may be of use for those projects which have beta or rc type tags. This allows one to define "Release" patterns via include and skip over non-release patterns via exclude. For the changelog use case, this allows release changelogs where history is not terminated by release candidate tags.

commit-ish

Optional Commit-ish object name(s) to describe.

Default: HEAD~

A commit-ish value is any which may point to a commit in git. You're probably already familiar with these (HEAD, HEAD~, HEAD^, @{ 2 weeks ago }, etc.). Check git's documentation for more details.

By default, git describe will point to HEAD which may result in the current tag on release builds. A user may want the current tag without manipulating GITHUB_REF as provided by GitHub Actions Environment Variables; pass commit-ish: "HEAD" as an input and ignore the warning logged by this action.

skip-unshallow

Optional Skip the unshallow operation: "true" or "false"

Default: false

This option allows for users who have already performed an unshallow operation to skip the additonal unshallow in this action. This is marked as optional because it will use default behavior if unspecified.

NOTE If you have already performed an unshallow in a previous step, you must pass skip-unshallow: "true" in any query-tag-action step following that unshallow. A future version may check and handle this logic gracefully without user input.

Outputs

tag

The tag determined by your inputs.

Example usage

uses: jimschubert/query-tag-action@v1 with: who-to-greet: 'Mona the Octocat'

name: Tagged
on: [release]

jobs:

  my_job:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2
    # Optionally: unshallow as a separate operation
    # - name: Unshallow
    #   run: git fetch --prune --unshallow
    - name: Find Tag
      id: tagger
      uses: jimschubert/query-tag-action@v1
      with:
        include: 'v*'
        exclude: '*-rc*'
        commit-ish: 'HEAD~'
        # if you unshallow in a separate step, use the following option:
        # skip-unshallow: 'true'
    - name: Show Tag
      id: display
      run: |
        echo 'Output from Find Tag: ${{steps.tagger.outputs.tag}}'

Testing

No automated tests are provided here because this action just builds a standard git describe command line invocation.

The example from above will produce the following command:

git fetch --prune --unshallow && git describe --tags --abbrev=0 --match 'v*' --exclude '*-rc*' HEAD~

The above command is built by the following parts:

  • skip-unshallow determines whether to include the git fetch --prune --unshallow && command part
  • include determines whether to generate --match and defines the value v*
  • exclude determines whether to generate --exclude and defines the value *-rc*
  • commit-ish determines whether to generate the command option HEAD~.

Please see tagged.yml for some use cases.

License

This project is licensed under Apache 2.0.

query-tag-action's People

Contributors

dbouclier avatar jimschubert avatar wdjunaidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

query-tag-action's Issues

get rid of --abbrev=0

I want to see output from git describe --tags which deliveres

6.1.0-27-gb293759

I do this

  - name: Find Tag
    id: tagger
    uses: jimschubert/query-tag-action@v1
    with:
      skip-unshallow: 'true'
  - name: Show Tag
    id: display
    run: |
      echo 'Output from Find Tag: ${{steps.tagger.outputs.tag}}'

And see in action log as output

git describe --tags --abbrev=0 --match '*' 'HEAD~' and delivers

6.1.0

Without --abbrev=0 and 'HEAD~'` I would see expected value how to archive this ?

eg.

`git describe --tags --match '*'

6.1.0-27-gb293759

Feature: --tags option

Hey Jim!

This action looks great! Thanks so far!

I'm currently using git describe --tags in a few projects and thinking about replacing my current CI/CD solution with GitHub Actions.

Is there a chance to add the --tags option to your action?

       --tags
           Instead of using only the annotated tags, use any tag found in refs/tags namespace. This
           option enables matching a lightweight (non-annotated) tag.

Or are there any conflicts with the existing inputs of your action?

Remove Summary Warnings

When executing this action, there are a couple of warnings that appear in the Workflow Summary:

The solutions are described in the provided links.
Thanks

Build failed with "fatal: No names found, cannot describe anything."

Hello,
My build failed with the following error
image

Here my configuration:

      - name: Find Tag
        id: tagger
        uses: jimschubert/query-tag-action@v2
        with:
          commit-ish: HEAD
          abbrev: 6

I guess it's a normal situation on a newly created repository without any tags.

maybe I did something wrong in the setup ?
maybe this GitHub action can handle this case, for example in that specific case the exit code can be 0 and the output empty, what do you think?

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.