Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

permissions:
contents: write
packages: write

jobs:
release:
Expand Down Expand Up @@ -60,6 +61,44 @@ jobs:
exit 1
fi

- name: Install NodeJS
uses: actions/setup-node@v6
with:
node-version: '22'
cache: yarn
registry-url: 'https://npm.pkg.github.com'
scope: '@scality'

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline

- name: Stamp package name and files
run: |
tmp=$(mktemp)
jq '.name = "@scality/arsenal" | .files = ["build"] | del(.private)' \
package.json > "$tmp"
mv "$tmp" package.json

- name: Build
run: yarn build

- name: Publish to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set +e
out=$(npm publish --ignore-scripts 2>&1); code=$?
echo "$out"
if [ "$code" -ne 0 ]; then
if echo "$out" | grep -qiE 'E409|cannot publish over|already exists'; then
echo "::warning::@scality/arsenal@$VERSION already published;" \
"continuing to finalize the release"
else
exit "$code"
fi
fi

- name: Create Release
uses: softprops/action-gh-release@v3
env:
Expand All @@ -68,4 +107,7 @@ jobs:
name: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.version }}
generate_release_notes: true
append_body: true
body: |
GitHub Packages: https://github.com/${{ github.repository }}/pkgs/npm/arsenal
target_commitish: ${{ github.sha }}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
},
"description": "Common utilities for the S3 project components",
"main": "build/index.js",
"types": "build/index.d.ts",
"publishConfig": {
"access": "restricted"
},
"repository": {
"type": "git",
"url": "git+https://github.com/scality/Arsenal.git"
Expand Down
5 changes: 5 additions & 0 deletions tests/workflows/release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ async function createTag(tag: string) {
const mockSteps = {
release: [
{ name: "Fail if release already exists", mockWith: "echo no-release-found" },
{ name: "Install NodeJS", mockWith: "echo skip-setup-node" },
{ name: "Install dependencies", mockWith: "echo skip-install" },
{ name: "Stamp package name and files", mockWith: "echo skip-stamp" },
{ name: "Build", mockWith: "echo skip-build" },
{ name: "Publish to GitHub Packages", mockWith: "echo skip-publish" },
{ name: "Create Release", mockWith: "echo skip-create-release" },
],
};
Expand Down
Loading