Coder Social home page Coder Social logo

action-test-renamed's Introduction

action-package-version-to-git-tag

Docker Image CI

This action runs that get ${version} from package.json and git tag ${version} for the repository.

  • Define the tag from package.json's version
    • also support git_tag_prefix option.
  • Push tag if the tag is not bumped on the repository

Usage

You create workflow file like .github/workflows/publish.yml.

name: publish
env:
  CI: true
on:
  push:
    branches:
      - master
    tags:
      - "!*"
jobs:
  release:
    name: Setup
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v1
      - name: setup Node
        uses: actions/setup-node@v1
      - name: package-version-to-git-tag
        uses: azu/action-package-version-to-git-tag@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          github_repo: ${{ github.repository }}
          git_commit_sha: ${{ github.sha }}
          git_tag_prefix: "v"

UseCase

  1. [Manual] Update Version: npm vession {patch,minor,major}
  2. [Manual] Push: git push or Merge the Pull Request
  3. [CI] Publish to npm and Push a tag to GitHub

This Release flow is defined in .github/workflows/publish.yml

name: publish
env:
  CI: true
on:
  push:
    branches:
      - master
    tags:
      - "!*"
jobs:
  release:
    name: Setup
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v1
      - name: setup Node
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
          registry-url: 'https://npm.pkg.github.com'
      - name: install
        run: npm install
      - name: test
        run: npm test
      # Publish to npm if this version is not published
      - name: publish
        run: |
          npx can-npm-publish --verbose && npm publish || echo "Does not publish"
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      # Push tag to GitHub if the version's tag is not tagged
      - name: package-version-to-git-tag
        uses: azu/action-package-version-to-git-tag@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          github_repo: ${{ github.repository }}
          git_commit_sha: ${{ github.sha }}

Options

inputs:
  version:
    description: 'define version explicitly. if it is not defined, use package.json version'
    required: false
  github_token:
    description: 'GITHUB_TOKEN'
    required: true
  git_commit_sha:
    description: 'Git commit SHA'
    required: true
  git_tag_prefix:
    description: "prefix for git tag. Example) 'v'"
    required: false
    default: ""
  github_repo:
    description: 'GitHub repository path. Example) azu/test'
    required: true

Release

npm version {patch,minor,major}
git push && git push --tags

Reference

FAQ

Error: npm ERR! code E401

Occur following error:

npx: installed 57 in 6.945s
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2019-12-26T08_02_20_108Z-debug.log

Please check NODE_AUTH_TOKEN

  env:
    NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

action-test-renamed's People

Contributors

azu avatar

Watchers

 avatar  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.