release-hello-world-component #31
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 packs = ["hello-world-windows", "hello-world-linux", "hello-world-mac"]; | |
let artifactsObj = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
for (var item of packs) { | |
console.log(item); | |
let requiredArtifact = artifactsObj.data.artifacts.filter((artifact) => { | |
return artifact.name == item | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: requiredArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
let workspace = `${process.env.GITHUB_WORKSPACE}/`; | |
fs.writeFileSync(workspace+item+'.zip', Buffer.from(download.data)); | |
}; | |
- name: 'Unzip Artifacts' | |
run: | | |
unzip hello-world-windows.zip | |
unzip hello-world-mac.zip | |
unzip hello-world-linux.zip | |
- name: 🟢 Node | |
uses: actions/setup-node@v4 | |
with: | |
always-auth: true | |
node-version: 18 | |
scope: '@naveed235812' | |
registry-url: https://registry.npmjs.org | |
- name: Publish Artifacts | |
run: | | |
import os | |
from glob import glob | |
artifacts = glob('naveed235812-hello-world-**-**.tgz*') | |
for artifact in artifacts: | |
os.system("npm publish --access public " + artifact) | |
shell: python | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} |