From f2bdc25fe1d809b140f08e86aad8c8bbfe950743 Mon Sep 17 00:00:00 2001 From: Joe Wagner Date: Mon, 2 Jan 2023 17:32:50 -0700 Subject: [PATCH 1/4] add remote workflow trigger binaries.yml --- .github/workflows/binaries.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 27370ab2..dbe5188b 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -59,3 +59,27 @@ jobs: push: true tags: textile/tableland:latest,textile/tableland:${{ github.ref_name }} platforms: linux/amd64, linux/arm64 + js-release: + runs-on: ubuntu-latest + steps: + - name: PR to publish this release via the npm package + uses: actions/github-script@v6 + with: + # TODO: I think we will need a token with greater permission than this, + # maybe TEXTILEIO_MACHINE_ACCESS_TOKEN will work? + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'tablelandnetwork', + repo: 'js-validator', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + release_version: ${{ github.ref_name }} + } + }).catch(error => error).then(response => { + core.debug(response); + if (response.status !== 204) { + core.setFailed(`create workflow_dispatch received status code ${response.status}`); + } + }); From 27336a51b69af9e73daed1d5cd45471b9e9be0f2 Mon Sep 17 00:00:00 2001 From: Joe Wagner Date: Tue, 3 Jan 2023 10:44:16 -0700 Subject: [PATCH 2/4] Change binary workflow token name --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index dbe5188b..5d3b3c62 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -67,7 +67,7 @@ jobs: with: # TODO: I think we will need a token with greater permission than this, # maybe TEXTILEIO_MACHINE_ACCESS_TOKEN will work? - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.TEXTILEIO_MACHINE_ACCESS_TOKEN }} script: | await github.rest.actions.createWorkflowDispatch({ owner: 'tablelandnetwork', From 01f65c7b01d68032dc82635e5c102e45ae4aa906 Mon Sep 17 00:00:00 2001 From: Joe Wagner Date: Tue, 3 Jan 2023 15:05:07 -0700 Subject: [PATCH 3/4] Cleanup and fixes to js-release workflow job --- .github/workflows/binaries.yml | 47 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 5d3b3c62..503694c7 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -61,25 +61,48 @@ jobs: platforms: linux/amd64, linux/arm64 js-release: runs-on: ubuntu-latest + if: ${{ success() }} + needs: [binaries] steps: + - run: echo "release_version ${{ github.ref_name }}" + - name: PR to publish this release via the npm package uses: actions/github-script@v6 with: - # TODO: I think we will need a token with greater permission than this, - # maybe TEXTILEIO_MACHINE_ACCESS_TOKEN will work? github-token: ${{ secrets.TEXTILEIO_MACHINE_ACCESS_TOKEN }} script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'tablelandnetwork', - repo: 'js-validator', - workflow_id: 'release-pr.yml', - ref: 'main', - inputs: { - release_version: ${{ github.ref_name }} + // This triggers the release-pr workflow in the js-validator repo + // which will create a pull request in that repo to update the binaries + // on npm with this release + try { + // TODO: switch back to 'tablelandnetwork' + const ownerOrg = 'joewagner'; + + // if the tag/release has a preceeding "v" we want to remove + // it and match standard symantics in the js ecosystem + let version = '${{ github.ref_name }}'; + if (/^v[0-9]/.test(version)) { + version = version.slice(1); } - }).catch(error => error).then(response => { - core.debug(response); + + const options = { + owner: ownerOrg, + repo: 'js-validator', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + release_version: version + } + }; + + console.log(options); + + const response = await github.rest.actions.createWorkflowDispatch(options); + if (response.status !== 204) { core.setFailed(`create workflow_dispatch received status code ${response.status}`); } - }); + } catch(err) { + console.log(err); + core.setFailed(err.message); + } From 7219027dcbac876887da734c21c5bbb24251f3d4 Mon Sep 17 00:00:00 2001 From: Joe Wagner Date: Wed, 4 Jan 2023 17:24:40 -0700 Subject: [PATCH 4/4] Fix org name in binaries workflow --- .github/workflows/binaries.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 503694c7..2abc2142 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -75,8 +75,7 @@ jobs: // which will create a pull request in that repo to update the binaries // on npm with this release try { - // TODO: switch back to 'tablelandnetwork' - const ownerOrg = 'joewagner'; + const ownerOrg = 'tablelandnetwork'; // if the tag/release has a preceeding "v" we want to remove // it and match standard symantics in the js ecosystem