release-hello-world-component #39
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 Hello-World Artifacts' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const packs = ["hello-world-windows", "hello-world-linux", "hello-world-mac"]; | |
const downloadPath = `${process.env.GITHUB_WORKSPACE}/`; | |
const obj = await github.rest.actions.listWorkflowRunArtifacts({repo: context.repo.repo, owner: context.repo.owner, run_id: context.payload.workflow_run.id}); | |
for (var item of packs) | |
{ | |
console.log(item); | |
const requiredPack = obj.data.artifacts.filter((pack) => { return pack.name == item})[0]; | |
const getArtifacts = await github.rest.actions.downloadArtifact({ archive_format: 'zip', repo: context.repo.repo, artifact_id: requiredPack.id, owner: context.repo.owner }); | |
const filePath = downloadPath + item + '.zip'; | |
fs.writeFileSync(filePath, Buffer.from(getArtifacts.data)); | |
}; | |
- name: 'Unzip Hello-World Artifacts' | |
run: | | |
unzip hello-world-windows.zip | |
unzip hello-world-mac.zip | |
unzip hello-world-linux.zip | |
- name: 🟢 Install Node.js 18 | |
uses: actions/setup-node@v4 | |
with: | |
always-auth: true | |
node-version: 18 | |
scope: '@naveed235812' | |
registry-url: https://registry.npmjs.org | |
- name: Release Hello-World Variants | |
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}} |