Giter Club home page Giter Club logo

image-version's Introduction

image-version

CLI tool and GitHub action to determine the container image version based on a git ref.
Take a look at program-version if you need the --version variant that programs normally output.

Installation

See the latest release for instructions.

Behavior

git ref image version
refs/heads/main latest
refs/heads/master latest
refs/heads/ft-refactor ft-refactor
refs/tags/v1.0.3 1.0.3
refs/tags/1.0.3 1.0.3
refs/tags/very-pinned (only removes v prefix on v[0-9]*) very-pinned
refs/tags/f1.0.3 (treated just like branches) f1.0.3
refs/tags/v v
e02d09699ffb56440f34cb7448a0bc436e3ae212 (i.e. non-symbolic) e02d0969
e02d09699ffb56440f34cb7448 (not 40 hex chars) error
master (no refs/heads/ prefix) error
v1.0.3 (no refs/tags/ prefix) error
refs/heads/ (empty branch name) error
refs/tags/ (empty tag name) error

CLI

Usage

image-version REF

When using μpkg you can retrieve the installed version of your package and pass that straight to this tool (git symbolic-ref is used as a fallback in order for it to work in your git repo while developing):

PKGROOT=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
version=$(image-version "$(jq -re '.version // empty' "$PKGROOT/upkg.json" 2>/dev/null || git -C "$PKGROOT" symbolic-ref HEAD)")

GitHub action

Parameters

  • ref: The git ref to calculate the version from, defaults to ${{ github.ref }}.

Usage

name: Release

on:
  push:
    branches: [ '*' ]
    tags: [ 'v*' ]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - id: image_version
      uses: orbit-online/[email protected]
    - uses: actions/checkout@v4
    - uses: docker/setup-buildx-action@v2
    - uses: docker/login-action@v2
      with:
        username: ${{ secrets.DOCKER_HUB_USERNAME }}
        password: ${{ secrets.DOCKER_HUB_TOKEN_RW }}
    - name: Build & push
      uses: docker/build-push-action@v5
      with:
        file: Dockerfile
        tags: orbit-online/my-prog:${{ steps.image_version.outputs.version }}
        push: true

image-version's People

Contributors

andsens avatar

Watchers

Mikkel Schmidt 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.