release-hello-world-component #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "release-hello-world-component" | |
on: | |
workflow_run: | |
workflows: [Build-And-Test-Component] | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
release-to-npmjs: | |
runs-on: windows-latest | |
permissions: | |
actions: write | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 'Download artifact' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "hello-world-windows" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/hello-world-windows.zip`, Buffer.from(download.data)); | |
- name: 'Unzip artifact' | |
run: unzip hello-world-windows.zip | |
- name: Get Package Filename | |
run: | | |
import os | |
from glob import glob | |
filename = glob('naveed235812-hello-world-windows-**.tgz*') | |
env_file = os.getenv('GITHUB_ENV') | |
with open(env_file, "a") as myfile: | |
myfile.write("PACK_NAME="+str([filename[0]])) | |
shell: python | |
- name: 🟢 Node | |
uses: actions/setup-node@v4 | |
with: | |
always-auth: true | |
node-version: 18 | |
scope: '@naveed235812' | |
registry-url: https://registry.npmjs.org | |
- name: 🚀 publish to npm.js | |
run: npm publish --access public ${{ env.PACK_NAME }} | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | |