Giter Site home page Giter Site logo

ozonophore / action-get-latest-tag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from actions-ecosystem/action-get-latest-tag

0.0 1.0 0.0 187 KB

✨ GitHub Action to get a latest Git tag

Home Page: https://github.com/marketplace/actions/actions-ecosystem-action-get-latest-tag

License: Apache License 2.0

Shell 89.58% Dockerfile 10.42%

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

Watchers

 avatar

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.