Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Gen GitHub Tag Action #252

Closed
wants to merge 20 commits into from
Closed

Next Gen GitHub Tag Action #252

wants to merge 20 commits into from

Conversation

beholdenkey
Copy link

@beholdenkey beholdenkey commented Apr 3, 2023

Summary of changes

This is a first iteration refactor. A lot of the code has been modified and updated. However, there is still a lot of room for improvement. I have a dev branch where I am testing out switching from the node server to using Python for the GitPython and SemVer Libraries. That will offer a greater level of performance and extensibility.

In addition, there is now a publish.yml that will build and publish the container image to the GitHub container registry. I saw this was something brought up in previous pull requests. I still need to tie the action into using that image, but it should help with the action time consumed.

Breaking Changes

There are not necessarily breaking changes. The functionality of the action has stayed the same; however,r a lot of the code supporting it has.

How changes have been tested

  • Local Unit Tests, Testing the container build/workflows; this will be the first iteration of the pull request to the master origin.

List any unknowns

  • Lots of changes/lots of unknowns. This will more than likely require iterations to complete changes and successfully merge.

Comment on lines +5 to +12
inputs:
DEFAULT_BUMP:
description: "Default semver bump type (major, minor, patch, or none)"
required: false
default: "minor"
DEFAULT_BRANCH:
description: "The default branch for the repository"
required: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why are you adding these two values as inputs when env-vars provide everything else? Keeping this way would mean, to adjust the examples to something like:

      - name: Bump version and push tag
        uses: anothrNick/[email protected] # Don't use @master unless you're happy to test the latest version
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          WITH_V: true
       with:
          DEFAULT_BUMP: "patch"

As the inputs need to be provided in a different matter. Also accessing the values would need to change to:

${{ inputs.DEFAULT_BUMP }}

Last but not least, they should be renamed to kebab-case default-bump.

I would delete lines 5 - 12 in this case

Copy link
Collaborator

@sbe-arg sbe-arg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this. On the phone it looks a considerable improvement in practice.

I have 0 time to check this pr this week but maybe @sammcj can have a look and test it.

Copy link
Collaborator

@sammcj sammcj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome effort! Really appreciate the contributions.

One thing I'd say especially given this is a big PR - it should really include some basic tests.

It doesn't have to be some big fancy testing framework but at least a script or functions that validate several scenarios that this may be used for.

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install cosign
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice! Great to see some security improvements!

@@ -0,0 +1,45 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!/usr/bin/env bash

Just so it's portable.

@@ -0,0 +1,45 @@
#!/bin/bash

set -euo pipefail
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice little addition I like to add to shell scripts to add set -x only if you're debugging:

DEBUG=${DEBUG:-false}

function debug() {
  echo "Debug mode enabled" >>"$GITHUB_STEP_SUMMARY"

  # Print all environment variables
  env | sort >>"$GITHUB_STEP_SUMMARY"
  echo -e "\n" >>"$GITHUB_STEP_SUMMARY"

	set -x
}

if [[ $DEBUG == 'true' ]]; then
  debug
fi

echo "MAIN Part: $MAIN_OUTPUT_PART" >>"$GITHUB_STEP_SUMMARY"
echo "PRE Tag: $PRE_OUTPUT_TAG" >>"$GITHUB_STEP_SUMMARY"
echo "PRE New tag: $PRE_OUTPUT_NEWTAG" >>"$GITHUB_STEP_SUMMARY"
echo "PRE Part: $PRE_OUTPUT_PART" >>"$GITHUB_STEP_SUMMARY"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little trick with this to make it render in a nice table can be something like this:

OUTPUT_SUMMARY="\n
| Output       | Value                 | \n
| ------------ | --------------------- | \n
|              |                       | \n
| MAIN Tag     | ${MAIN_OUTPUT_TAG}    | \n
| MAIN New tag | ${MAIN_OUTPUT_NEWTAG} | \n
| MAIN Part    | ${MAIN_OUTPUT_PART}   | \n
| PRE Tag      | ${PRE_OUTPUT_TAG}     | \n
| PRE New tag  | ${PRE_OUTPUT_NEWTAG}  | \n
| PRE Part     | ${PRE_OUTPUT_PART}    | \n
"

echo -e "$OUTPUT_SUMMARY" >>"$GITHUB_STEP_SUMMARY"


Examples of unacceptable behaviour include:
Examples of unacceptable behavior include:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour is the correct international spelling.

Behavior is specific to American.


# Test for #none bump
if [[ $MAIN_OUTPUT_PART == "none" ]]; then
if [[ $MAIN_OUTPUT_TAG == "$MAIN_OUTPUT_NEWTAG" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the variable on the left of the comparison should be quoted as well.

}

main="$(verlt "$MAIN_OUTPUT_TAG" "$MAIN_OUTPUT_NEWTAG" && true || false)"
pre="$(verlt "$PRE_OUTPUT_TAG" "$PRE_OUTPUT_NEWTAG" && true || false)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird to have double quotes inside a double quoted string but it does seem to work on my machine as well 🤷

# set outputs
setOutput "new_tag" "$new"
setOutput "part" "$part"
setOutput "tag" "$new" # this needs to go in v2 is breaking change
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like this comment to remain specially since broke the flows for a LOT lots of people

@beholdenkey beholdenkey closed this by deleting the head repository May 26, 2023
@sbe-arg
Copy link
Collaborator

sbe-arg commented May 26, 2023

:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants