mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 22:53:55 -07:00
[Protocol] Simplify publish workflow
- Coerce Cockatrice release tags (YYYY-MM-DD-Release-X.Y.Z) to semver so npm version accepts them; hard-fail on tag-format drift. - Replace hand-rolled npm publish with JS-DevTools/npm-publish@v4 for native skip-when-unchanged and OIDC provenance. - Drop redundant publish flag and workflow_dispatch version input. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b870ce0a4a
commit
7f5d8732bb
1 changed files with 24 additions and 36 deletions
60
.github/workflows/protocol-publish.yml
vendored
60
.github/workflows/protocol-publish.yml
vendored
|
|
@ -11,11 +11,6 @@ on:
|
||||||
- '.github/workflows/protocol-publish.yml'
|
- '.github/workflows/protocol-publish.yml'
|
||||||
- 'libcockatrice_protocol/**'
|
- 'libcockatrice_protocol/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
description: 'Semver to publish (e.g. 15.0.0). Leave blank to dry-run only.'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "${{ github.workflow }} @ ${{ github.ref_name }}"
|
group: "${{ github.workflow }} @ ${{ github.ref_name }}"
|
||||||
|
|
@ -31,6 +26,7 @@ jobs:
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
@ -40,36 +36,24 @@ jobs:
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
registry-url: 'https://npm.pkg.github.com'
|
|
||||||
scope: '@cockatrice'
|
|
||||||
|
|
||||||
- name: Determine package version
|
- name: Determine package version
|
||||||
id: pkgver
|
id: pkgver
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
case "$GITHUB_EVENT_NAME" in
|
# Cockatrice stable tags: YYYY-MM-DD-Release-X.Y.Z. Non-release events get a
|
||||||
release)
|
# placeholder version and the publish step is skipped.
|
||||||
version="${{ github.event.release.tag_name }}"
|
tag="${{ github.event.release.tag_name }}"
|
||||||
version="${version#v}"
|
if [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
|
||||||
publish=true
|
if [[ "$tag" =~ Release-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||||
;;
|
echo "version=${BASH_REMATCH[1]}" >>"$GITHUB_OUTPUT"
|
||||||
workflow_dispatch)
|
else
|
||||||
version="${{ inputs.version }}"
|
echo "::error::Release tag '$tag' does not end in Release-X.Y.Z; refusing to publish."
|
||||||
if [[ -n "$version" ]]; then
|
exit 1
|
||||||
version="${version#v}"
|
fi
|
||||||
publish=true
|
else
|
||||||
else
|
echo "version=0.0.0-dryrun" >>"$GITHUB_OUTPUT"
|
||||||
version="0.0.0-manual"
|
fi
|
||||||
publish=false
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*) # pull_request
|
|
||||||
version="0.0.0-pr${{ github.event.pull_request.number }}"
|
|
||||||
publish=false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "version=$version" >>"$GITHUB_OUTPUT"
|
|
||||||
echo "publish=$publish" >>"$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Assemble package
|
- name: Assemble package
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -86,7 +70,7 @@ jobs:
|
||||||
npm --prefix "$pkg" version --no-git-tag-version --allow-same-version "$PKG_VERSION"
|
npm --prefix "$pkg" version --no-git-tag-version --allow-same-version "$PKG_VERSION"
|
||||||
|
|
||||||
- name: Pack and inspect (dry-run)
|
- name: Pack and inspect (dry-run)
|
||||||
if: ${{ steps.pkgver.outputs.publish != 'true' }}
|
if: ${{ github.event_name != 'release' }}
|
||||||
working-directory: build/protocol-package
|
working-directory: build/protocol-package
|
||||||
run: |
|
run: |
|
||||||
npm pack
|
npm pack
|
||||||
|
|
@ -94,8 +78,12 @@ jobs:
|
||||||
tar -tzf ./*.tgz | sort
|
tar -tzf ./*.tgz | sort
|
||||||
|
|
||||||
- name: Publish to GitHub Packages
|
- name: Publish to GitHub Packages
|
||||||
if: ${{ steps.pkgver.outputs.publish == 'true' }}
|
if: ${{ github.event_name == 'release' }}
|
||||||
working-directory: build/protocol-package
|
uses: JS-DevTools/npm-publish@v4
|
||||||
env:
|
with:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package: build/protocol-package
|
||||||
run: npm publish
|
registry: https://npm.pkg.github.com
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
access: restricted
|
||||||
|
provenance: true
|
||||||
|
strategy: upgrade
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue