Code Monkey home page Code Monkey logo

action-get-latest-tag's Introduction

Action Get Latest Tag

actions-workflow-lint release license

This is a GitHub Action to get a latest Git tag.

It would be more useful to use this with other GitHub Actions' outputs.

Inputs

NAME DESCRIPTION TYPE REQUIRED DEFAULT
semver_only Whether gets only a tag in the shape of semver. v prefix is accepted for tag names. bool false false
initial_version The initial version. Works only when inputs.with_initial_version == true. string false v0.0.0
with_initial_version Whether returns inputs.initial_version as outputs.tag if no tag exists. true and false are available. bool false true

If inputs.semver_only is true, the latest tag among tags with semver will be set for outputs.tag.

This input is useful for versioning that binds a major version is the latest of that major version (e.g., v1 == v1.*), like GitHub Actions. In such a case, the actual latest tag is a major version, but the version isn't as we expected when we want to work with semver.

Let's say you did the following versioning.

$ git tag v1.0.0 && git push origin v1.0.0
$ # some commits...
$ git tag v1.1.0 && git push origin v1.1.0
$ git tag v1 && git push origin v1 # bind v1 to v1.1.0.

In such a case, outputs.tag varies like this:

  • inputs.semver_only=false -> outputs.tag=v1
  • inputs.semver_only=true -> outputs.tag=v1.1.0

Outputs

NAME DESCRIPTION TYPE
tag The latest tag. If no tag exists and inputs.with_initial_version == false, this value is ''. string

Example

name: Push a new tag with Pull Request

on:
  pull_request:
    types: [closed]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-release-label@v1
        id: release-label
        if: ${{ github.event.pull_request.merged == true }}

      - uses: actions-ecosystem/action-get-latest-tag@v1
        id: get-latest-tag
        if: ${{ steps.release-label.outputs.level != null }}

      - uses: actions-ecosystem/action-bump-semver@v1
        id: bump-semver
        if: ${{ steps.release-label.outputs.level != null }}
        with:
          current_version: ${{ steps.get-latest-tag.outputs.tag }}
          level: ${{ steps.release-label.outputs.level }}

      - uses: actions-ecosystem/action-push-tag@v1
        if: ${{ steps.release-label.outputs.level != null }}
        with:
          tag: ${{ steps.bump-semver.outputs.new_version }}
          message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}'

For a further practical example, see .github/workflows/release.yml.

License

Copyright 2020 The Actions Ecosystem Authors.

Action Get Latest Tag is released under the Apache License 2.0.

action-get-latest-tag's People

Contributors

micnncim avatar sbx0r avatar tokestermw 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

Watchers

 avatar  avatar  avatar

action-get-latest-tag's Issues

Generates warning about set-output command being deprecated

What happened

I used this action in a recent workflow and it generated a warning:

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/

What you expected to happen

No such warning

How to reproduce it

Run any GitHub Actions workflow containing this action.

Environment

Action failed suddenly

Hey there.

I'm using actions-ecosystem/action-get-latest-tag@v1 in my Github Actions workflow and worked as expected.

The step aborted suddenly with no reason apparently and logs shows the following:
imagen

Is it an infrequent scenario or it should be receive a patch?

Thanks in advance.

Occasionally gives the wrong version

What happened

Sometimes this gives me the wrong version. I'm not sure why. For example, see the output of this workflow. The latest tag should be 2.9.0, but this action is repeatedly giving 2.8.1 as the latest (which was also created earlier).

Screen Shot 2021-03-03 at 9 23 46 PM

What you expected to happen

I expected that I would get the highest release for the repo by default.

How to reproduce it

I'm not sure

fatal: unsafe repository ('/github/workspace' is owned by someone else)

What happened

I was just executing a workflow with the action-get-latest-tag task from a tag push trigger (tag 1.4.0) as every time but it keeps failing. I didn't notice any changes to this repository so there's a good chance this is isn't a bug with the action itself (but maybe a deprecation?).

Possibly caused by CVE-2022-24765 mitigation

What you expected to happen

The action should fetch the latest tag without failing.

How to reproduce it

  • Create workflow with actions-ecosystem/action-get-latest-tag@v1 actions
  • Execute via push tag trigger

Environment

Workflow

name: "Deploy: Production"

on:
  push:
    tags: [ "*" ]

env:
  ENVIRONMENT: production

jobs:
  preflight:
    name: "Preflight"
    runs-on: ubuntu-latest
    outputs:
      latest_tag: ${{ steps.latest-tag.outputs.tag }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - id: latest-tag
        name: Find latest tag
        uses: actions-ecosystem/action-get-latest-tag@v1

Logs

Run actions-ecosystem/action-get-latest-tag@v1
  with:
    semver_only: false
    initial_version: v0.0.0
    with_initial_version: true
  env:
    ENVIRONMENT: production

/usr/bin/docker run
--name REDACTED_REDACTED
--label REDACTED
--workdir /github/workspace
--rm 
-e ENVIRONMENT             -e REPOSITORY_PREFIX     -e INPUT_SEMVER_ONLY  -e INPUT_INITIAL_VERSION -e INPUT_WITH_INITIAL_VERSION 
-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 
-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/REDACTED/REDACTED":"/github/workspace" REDACTED:REDACTED

fatal: unsafe repository ('/github/workspace' is owned by someone else)
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace

The `set-output` command is deprecated and will be disabled soon

What happened

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/

What you expected to happen

Warning should not be displayed
https://github.com/actions-ecosystem/action-get-latest-tag/blob/main/entrypoint.sh last line should be corrected

How to reproduce it

Would be enough if someone will use this action on github

Environment

Does not matter

Pre-release handling

What you want to add

It's not clear how this behaves with pre-releases, so it'd be great to see a documentation update, but the best outcome would be an input for whether or not to include pre-release tags.

Why this is needed

The latest tag someone wants may or may not be a pre-release version, e.g. 0.5.0 vs 1.0.0-beta.1 - which would be returned?

latest tag if no tag exists

Hi

Based on the documentation it seems we can use this action even in repo which doesnt yet have any tags exist.

when using it like the following:

  • name: Get Latest Tag
    uses: actions-ecosystem/action-get-latest-tag@v1
    with:
    with_initial_version: true # although default
    initial_version: '1.0.0'
    id: get-latest-tag

this step failed with fatal: No names found, cannot describe anything and does not returns the initial_version as the tag...
what am i missing here?

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.