Skip to content

fixed undefined

fixed undefined #79

Workflow file for this run

name: Release
on:
push:
branches:
- main
paths:
- 'src/**'
- 'package.json'
- 'Dockerfile'
- '.dockerignore'
- '.github/workflows/release.yaml'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 1.0.0). Leave blank to bump patch.'
required: false
default: ''
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Bump version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
npm version ${{ github.event.inputs.version }} --no-git-tag-version
else
npm version patch --no-git-tag-version
fi
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Commit version bump (signed, via GitHub API)
id: commit
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'package.json';
const contents = fs.readFileSync(path, 'utf8');
const version = '${{ steps.version.outputs.version }}';
const mutation = `
mutation ($input: CreateCommitOnBranchInput!) {
createCommitOnBranch(input: $input) {
commit { oid }
}
}
`;
const result = await github.graphql(mutation, {
input: {
branch: {
repositoryNameWithOwner: `${context.repo.owner}/${context.repo.repo}`,
branchName: 'main',
},
message: { headline: `chore: bump version to v${version} [skip ci]` },
fileChanges: {
additions: [
{ path, contents: Buffer.from(contents).toString('base64') },
],
},
expectedHeadOid: context.sha,
},
});
core.setOutput('sha', result.createCommitOnBranch.commit.oid);
- name: Create version tag
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.version.outputs.version }}';
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/v${version}`,
sha: '${{ steps.commit.outputs.sha }}',
});
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/onepacerr:v${{ steps.version.outputs.version }}
ghcr.io/${{ github.repository_owner }}/onepacerr:latest
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.version.outputs.version }}
org.opencontainers.image.revision=${{ steps.commit.outputs.sha }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
generate_release_notes: true