Skip to content

Create package build and publish#1

Open
Sephsekla wants to merge 1 commit intomainfrom
npm-build-publish
Open

Create package build and publish#1
Sephsekla wants to merge 1 commit intomainfrom
npm-build-publish

Conversation

@Sephsekla
Copy link
Copy Markdown
Collaborator

@Sephsekla Sephsekla commented Jul 27, 2023

Create a workflow to build an npm package, and publish it to both a github release.

The recommended use here is to reference this workflow in other repos, and attach it to pushing a tag (so manually run npm version and push, this will do the rest).

    push:
        tags:
            - '*.*.*'

It's largely based on what we've added on https://github.com/WordPress/wp-feature-notifications/ with some changes.

This will need a readme and some proper documentation adding, but I'd appreciate an early review of the approach.

@Sephsekla Sephsekla self-assigned this Jul 27, 2023
Copy link
Copy Markdown

@roborourke roborourke left a comment

Choose a reason for hiding this comment

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

Is this only manually run?

Is the idea that this is copied across to other projects or referenced directly?

  • If it's to be copied across, I think it needs a bunch of comments adding to explain each step, and possibly to include alternative examples for triggers that can be uncommented
  • If it's to be referenced directly then what other smart defaults could we provide, e.g. multiple versions of this workflow with different triggers preconfigured like on.push.tags etc...

Given it's not there yet it'd be great to get a README.md with examples of how to use this, because I don't really know off the top of my head. It'll help this effort to gain traction.

@kadamwhite
Copy link
Copy Markdown
Contributor

kadamwhite commented Dec 3, 2024

Discussed briefly with @Sephsekla . The usage would be to link to this repository from a project, so that we reference it directly rather than copying code.

jobs:
    build:
        uses: humanmade/hm-github-actions/.github/workflows/npm-package-release.yml@5bfc0e46c22d2724570bdc356c2e5658679d8e2e # v1.2.3

(note, linking to sha vs tag is recommended by GitHub: https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions )

This raises the question of repo structure. Should we do away with the .github folder here? Or is it valuable, so that if we have any dogfooded github actions in this repo, that they can actually run IN this repo?

@tomjn
Copy link
Copy Markdown

tomjn commented Mar 11, 2025

This raises the question of repo structure. Should we do away with the .github folder here? Or is it valuable, so that if we have any dogfooded github actions in this repo, that they can actually run IN this repo?

The uses line definitely looks a bit fugly, what if .github/workflows/npm-package-release.yml referenced uses: humanmade/hm-github-actions/npm-package-release.yml? Could we use a subfolder? And does it still make sense to include hm- in the repo title?

description: 'Which version of node to use for build'
type: string
required: false
default: '16.x'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we want a newer version of node? Perhaps what's used in the current WP release


steps:
- name: Checkout
uses: actions/checkout@v3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we want to pin a commit? There's a v4 of this action out

uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a v4 of this action too

run: echo "zip=$(npm pack)" > "$GITHUB_OUTPUT"

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a v2 of this action

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