Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
workerbee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
workerbee
Commits
bc201bc1
Verified
Commit
bc201bc1
authored
7 months ago
by
Mateusz Tyszczak
Browse files
Options
Downloads
Patches
Plain Diff
Add GitHub publish workflow for npm provenance
parent
04231b2f
No related branches found
No related tags found
No related merge requests found
Pipeline
#103390
passed
7 months ago
Stage: .pre
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.github/workflows/npm_publish.yml
+21
-0
21 additions, 0 deletions
.github/workflows/npm_publish.yml
scripts/publish_by_tag.sh
+36
-0
36 additions, 0 deletions
scripts/publish_by_tag.sh
with
57 additions
and
0 deletions
.github/workflows/npm_publish.yml
0 → 100644
+
21
−
0
View file @
bc201bc1
name
:
Publish Package to npmjs
on
:
push
:
tags
:
-
"
*.*.*"
# This ensures the workflow runs on any newly created tag
workflow_dispatch
:
# This allows the workflow to be triggered manually
jobs
:
build
:
runs-on
:
ubuntu-latest
permissions
:
contents
:
read
id-token
:
write
steps
:
-
uses
:
actions/checkout@v4
-
uses
:
actions/setup-node@v4
with
:
node-version
:
'
18'
registry-url
:
'
https://registry.npmjs.org'
-
run
:
./scripts/publish_by_tag.sh 452 "${{ github.ref_name }}" "dist/hiveio-workerbee-${{ github.ref_name }}.tgz" build
env
:
NODE_AUTH_TOKEN
:
${{ secrets.NPM_TOKEN }}
This diff is collapsed.
Click to expand it.
scripts/publish_by_tag.sh
0 → 100755
+
36
−
0
View file @
bc201bc1
#!/bin/bash
# This script is intended to download artifacts from the latest pipeline with
# job named "build" from given GitLab project, and then publish it to npm with provenance
#
# Example usage for project WorkerBee:
#
# ./scripts/publish_by_tag.sh 452 1.27.6-rc5 "dist/hiveio-workerbee-1.27.6-rc5.tgz" build
set
-e
PROJECT_ID
=
${
1
:?Missing
arg \#1 - GitLab project id
}
TAG
=
${
2
:?Missing
arg \#2 - TAG name
}
TGZ_PATH
=
${
3
:?Missing
arg \#3 - TGZ Artifacts filepath
}
JOB_NAME
=
${
4
:?Missing
arg \#4 - Job name containing the tgz artifacts
}
API_PREFIX
=
"https://gitlab.syncad.com/api/v4/projects/
${
PROJECT_ID
}
"
CHECK_REPO_EXISTANCE_ERROR_MSG
=
$(
curl
-s
"
${
API_PREFIX
}
"
| jq
-r
".message"
)
if
[
"
${
CHECK_REPO_EXISTANCE_ERROR_MSG
}
"
!=
"null"
]
;
then
echo
"Error fetching source repository. Cause:
\"
${
CHECK_REPO_EXISTANCE_ERROR_MSG
}
\"
"
exit
1
fi
TGZ_PULL_URL
=
"
${
API_PREFIX
}
/jobs/artifacts/
${
TAG
}
/raw/
${
TGZ_PATH
}
?job=build"
TARGET_FILEPATH
=
/tmp/
$(
basename
"
${
TGZ_PATH
}
"
)
echo
"Downloading artifact from
\"
${
TGZ_PULL_URL
}
\"
to
\"
${
TARGET_FILEPATH
}
\"
"
curl
-o
"
${
TARGET_FILEPATH
}
"
"
${
TGZ_PULL_URL
}
"
echo
"Publishing artifacts to npm with provenance for tag
\"
${
TAG
}
\"
"
npm publish
--access
public
--provenance
"
${
TARGET_FILEPATH
}
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment