From 623983d44e7c41fef4a4f428f27cceaa318f4cd0 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 05:49:56 -0500 Subject: [PATCH 01/12] Update release script to include packaging step. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5618fa1..aaa991c9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "url": "https://github.com/y-scope/clp-ffi-js/issues" }, "scripts": { - "release": "git diff --exit-code && npm publish" + "release": "git diff --exit-code && task package && npm publish" }, "type": "module", "files": [ From dc7501b0703297a7c53245fcc1e535b6a769a1a2 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 05:50:22 -0500 Subject: [PATCH 02/12] Add GitHub Actions workflow for publishing to npm. --- .github/workflows/publish-npm.yml | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 00000000..e29fc177 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,43 @@ +name: "publish-npm" + +on: + release: + types: ["published"] + workflow_dispatch: + +permissions: {} + +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + with: + submodules: "recursive" + + - name: "Install task" + run: "npm install -g @go-task/cli" + + - name: "Run package task" + run: "task package" + + - name: "Upload build artifacts" + uses: "actions/upload-artifact@v4" + with: + path: "dist/" + + publish-npm: + needs: ["build"] + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + - uses: "actions/download-artifact@v4" + + - uses: "actions/setup-node@v4" + with: + node-version: 22 + registry-url: "https://registry.npmjs.org/" + + - run: "npm publish" + env: + NODE_AUTH_TOKEN: "${{secrets.NPM_TOKEN}}" From 586bd066e0c26f76ae9056577d1a871324b6d79a Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 06:11:19 -0500 Subject: [PATCH 03/12] Add workflow step to create and push a new branch. --- .github/workflows/publish-npm.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index e29fc177..66fc4165 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -41,3 +41,21 @@ jobs: - run: "npm publish" env: NODE_AUTH_TOKEN: "${{secrets.NPM_TOKEN}}" + + create-branch: + needs: ["publish-npm"] + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - name: "Configure Git" + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: "Create and push branch" + run: | + git checkout -b ${{github.ref_name}} + git push origin ${{github.ref_name}} From 4b7a2be3f5bb980a714f45acf41d578e2425f215 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 06:11:49 -0500 Subject: [PATCH 04/12] Update release trigger type from "published" to "created" in publish workflow. --- .github/workflows/publish-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 66fc4165..91b9e020 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -2,7 +2,7 @@ name: "publish-npm" on: release: - types: ["published"] + types: ["created"] workflow_dispatch: permissions: {} From 09a9f0494c7f266c52893c55964aaf9846f4efbf Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 06:45:31 -0500 Subject: [PATCH 05/12] Add write permissions for creating a new branch. --- .github/workflows/publish-npm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 91b9e020..3ca35883 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -45,6 +45,9 @@ jobs: create-branch: needs: ["publish-npm"] runs-on: "ubuntu-latest" + permissions: + # For creating a new branch + contents: write steps: - uses: "actions/checkout@v4" with: From 2a750757b759ec1a0e31f0ec3efb73831840abc4 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 06:48:02 -0500 Subject: [PATCH 06/12] Specify pushing to branch; wrap new-branch-name & push-ref with quotes. --- .github/workflows/publish-npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 3ca35883..67dbe43c 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -60,5 +60,5 @@ jobs: - name: "Create and push branch" run: | - git checkout -b ${{github.ref_name}} - git push origin ${{github.ref_name}} + git checkout -b "${{github.ref_name}}" + git push origin "refs/heads/${{github.ref_name}}" From 5c41d16faa6a4d948eb5069c1011ca65faba9c89 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Sun, 22 Dec 2024 07:28:46 -0500 Subject: [PATCH 07/12] Quote permission value. --- .github/workflows/publish-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 67dbe43c..4862e3f2 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -47,7 +47,7 @@ jobs: runs-on: "ubuntu-latest" permissions: # For creating a new branch - contents: write + contents: "write" steps: - uses: "actions/checkout@v4" with: From 7713b9fd6c50497ebf8ea7d3ee73c95c4a62b542 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 21:09:44 -0500 Subject: [PATCH 08/12] Use `--global` instead of `-g` in `npm install` - Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- .github/workflows/publish-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 4862e3f2..c8ab4680 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -16,7 +16,7 @@ jobs: submodules: "recursive" - name: "Install task" - run: "npm install -g @go-task/cli" + run: "npm install --global @go-task/cli" - name: "Run package task" run: "task package" From 42f4550ed48811a6b680ee7624f450e000b7042d Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 21:11:54 -0500 Subject: [PATCH 09/12] Specify file upload retention day and no file found resolution - Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- .github/workflows/publish-npm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index c8ab4680..3deb3e87 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -25,6 +25,8 @@ jobs: uses: "actions/upload-artifact@v4" with: path: "dist/" + if-no-files-found: "error" + retention-days: 1 publish-npm: needs: ["build"] From f608eeb29ebe17303292ddd1cc60176e927df55f Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 21:22:27 -0500 Subject: [PATCH 10/12] Remove `name` for command "task package". --- .github/workflows/publish-npm.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 3deb3e87..c16f5357 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -18,8 +18,7 @@ jobs: - name: "Install task" run: "npm install --global @go-task/cli" - - name: "Run package task" - run: "task package" + - run: "task package" - name: "Upload build artifacts" uses: "actions/upload-artifact@v4" From b997a072418675deac6beca97b44d382d1711f19 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 21:50:33 -0500 Subject: [PATCH 11/12] Rename workflow to "publish-to-npm". --- .github/workflows/{publish-npm.yml => publish-to-npm.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{publish-npm.yml => publish-to-npm.yml} (97%) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-to-npm.yml similarity index 97% rename from .github/workflows/publish-npm.yml rename to .github/workflows/publish-to-npm.yml index c16f5357..7fe7d568 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -1,4 +1,4 @@ -name: "publish-npm" +name: "publish-to-npm" on: release: @@ -27,7 +27,7 @@ jobs: if-no-files-found: "error" retention-days: 1 - publish-npm: + publish-to-npm: needs: ["build"] runs-on: "ubuntu-latest" steps: From 57bebedbdd742580497ebb62d05702ec4c0ee410 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 21:51:14 -0500 Subject: [PATCH 12/12] Remove "create-branch" workflow job. --- .github/workflows/publish-to-npm.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml index 7fe7d568..fb8f304c 100644 --- a/.github/workflows/publish-to-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -42,24 +42,3 @@ jobs: - run: "npm publish" env: NODE_AUTH_TOKEN: "${{secrets.NPM_TOKEN}}" - - create-branch: - needs: ["publish-npm"] - runs-on: "ubuntu-latest" - permissions: - # For creating a new branch - contents: "write" - steps: - - uses: "actions/checkout@v4" - with: - fetch-depth: 0 - - - name: "Configure Git" - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: "Create and push branch" - run: | - git checkout -b "${{github.ref_name}}" - git push origin "refs/heads/${{github.ref_name}}"