Skip to content

Configure Dependabot to use npm and daily updates #14

Configure Dependabot to use npm and daily updates

Configure Dependabot to use npm and daily updates #14

Workflow file for this run

name: Build Release
on:
push:
branches:
- master
- main
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (for example v1.2.3). Can be existing or new."
required: true
type: string
permissions:
contents: write
concurrency:
group: build-release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release target
id: ref
shell: bash
run: |
set -euo pipefail
git fetch --force --tags
SHOULD_PUBLISH="false"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
SHOULD_PUBLISH="true"
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
git checkout --detach "refs/tags/${TAG}"
else
echo "::notice::Tag ${TAG} does not exist yet. Building current commit and creating tag via release."
fi
elif [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG="${GITHUB_REF_NAME}"
SHOULD_PUBLISH="true"
git checkout --detach "refs/tags/${TAG}"
else
TAG="snapshot-${GITHUB_SHA::7}"
echo "::notice::Branch push detected (${GITHUB_REF_NAME}); building snapshot artifacts with tag ${TAG}."
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "should_publish=${SHOULD_PUBLISH}" >> "$GITHUB_OUTPUT"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.22.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Install dependencies
shell: bash
run: |
set -euo pipefail
if [ -f pnpm-lock.yaml ]; then
pnpm install --frozen-lockfile
else
pnpm install --no-frozen-lockfile
fi
- name: Build
run: pnpm build
- name: Package release assets
id: pkg
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.ref.outputs.tag }}"
STAGE="release-${TAG}"
mkdir -p "${STAGE}"
cp -r .output "${STAGE}/.output"
cp package.json "${STAGE}/package.json"
if [ -f README.md ]; then cp README.md "${STAGE}/README.md"; fi
if [ -f LICENSE ]; then cp LICENSE "${STAGE}/LICENSE"; fi
if [ -f DOCKERHUB_OVERVIEW.md ]; then cp DOCKERHUB_OVERVIEW.md "${STAGE}/DOCKERHUB_OVERVIEW.md"; fi
ARCHIVE="nitrocraft-${TAG}-node-server.tar.gz"
tar -czf "${ARCHIVE}" -C "${STAGE}" .
SHA="nitrocraft-${TAG}-node-server.sha256"
sha256sum "${ARCHIVE}" | awk '{print $1}' > "${SHA}"
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT"
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release
if: steps.ref.outputs.should_publish == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ref.outputs.tag }}
target_commitish: ${{ steps.ref.outputs.commit }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
${{ steps.pkg.outputs.archive }}
${{ steps.pkg.outputs.sha }}
- name: Upload snapshot artifacts
if: steps.ref.outputs.should_publish != 'true'
uses: actions/upload-artifact@v4
with:
name: nitrocraft-${{ steps.ref.outputs.tag }}-node-server
path: |
${{ steps.pkg.outputs.archive }}
${{ steps.pkg.outputs.sha }}