npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

general-autotag

v1.0.0

Published

Automatically generate new tags by extracting their names from a given source file

Downloads

3

Readme

General AutoTag :bookmark_tabs:

This action will read a chosen source file and extract the current version from it. It will then compare it to the project's known tags and, if a corresponding tag does not exist, it will be created.

Forked from Autotag, which worked specifically with Node projects. This approach is more flexible and works with different programming languages.

Usage

The following is an example .github/main.workflow that will execute when a push to the master branch occurs. It will extract the current version number from package.json:

name: My Workflow

on:
  push:
    paths:
    - package.json
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: jaliborc/[email protected]
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        source_file: "package.json"
        extraction_regex: "\\s*\"version\"s*:\\s*\"([\\d\\.]+)\""

To make this work, the workflow must have the checkout action before the tagging action.

This order is important!

- uses: actions/checkout@master
- uses: jaliborc/[email protected]

If the repository is not checked out first, the action cannot find the chosen source file.

Configuration

Mandatory

The GITHUB_TOKEN, a source_file and an extraction_regex must be passed in. Without this, it is not possible to create a new tag. Make sure the autotag action looks like the following example:

- uses: jaliborc/[email protected]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    source_file: # the file in your repository that contains the version name
    extraction_regex: # some regex pattern

The action will automatically extract the github token at runtime. DO NOT MANUALLY ENTER YOUR TOKEN. If you put the actual token in your workflow file, you're make it accessible in plaintext to anyone who ever views the repository (it will be in your git history).

Optional

There are a few options to customize how the tag is created.

  1. tag_format

    By default, the action will tag versions exactly as matched in the source file. Prefixes and suffixes can be used to add text around the tag name. For example, if the current version is 1.0.0 and the tag_format is set to v{version} (beta), then the tag would be labeled as v1.0.0 (beta).

    - uses: jaliborc/[email protected]
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        source_file: "package.json"
        extraction_regex: "(\\d+\\.\\d+\\.\\d+)"
        tag_format: "v{version} (beta)"
  2. tag_message

    This is the annotated commit message associated with the tag. By default, a changelog will be generated from the commits between the latest tag and the new tag (HEAD). This will override that with a hard-coded message.

    - uses: jaliborc/[email protected]
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        source_file: "project.toc"
        extraction_regex: "Version:\\s*(\\d+)"
        tag_message: "Custom message goes here."

Output

If you are building an action that runs after this one, be aware this action produces several outputs:

  1. tagname will be empty if no tag was created, or it will be the value of the new tag.
  2. tagsha: The SHA of the new tag.
  3. taguri: The URI/URL of the new tag reference.
  4. tagmessage: The message applied to the tag reference (this is what shows up on the tag screen on GitHub).
  5. version will be the version attribute found in the chosen source file.