Skip to content

Commit 402ce99

Browse files
committed
Simplify publishing action.
1 parent a591bdb commit 402ce99

File tree

1 file changed

+7
-134
lines changed

1 file changed

+7
-134
lines changed
Lines changed: 7 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,38 @@
11
name: Publish State Packages
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
state:
7-
description: 'State to publish (or "all" for all states)'
8-
required: true
9-
type: choice
10-
options:
11-
- all
12-
- california
13-
- colorado
14-
version:
15-
description: 'Version to publish (e.g., 1.0.0)'
16-
required: true
17-
type: string
18-
194
push:
205
tags:
216
- 'v*'
22-
- '*-v*'
237

248
permissions:
9+
id-token: write
2510
contents: read
2611

2712
jobs:
28-
setup:
29-
runs-on: ubuntu-latest
30-
outputs:
31-
states: ${{ steps.determine.outputs.states }}
32-
version: ${{ steps.determine.outputs.version }}
33-
steps:
34-
- uses: actions/checkout@v4
35-
36-
- name: Determine states and version
37-
id: determine
38-
run: |
39-
# Get all available states from overlay directories
40-
ALL_STATES=$(ls -d packages/schemas/openapi/overlays/*/ 2>/dev/null | \
41-
xargs -n1 basename | \
42-
jq -R -s -c 'split("\n") | map(select(length > 0))')
43-
44-
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
45-
# Manual trigger
46-
VERSION="${{ github.event.inputs.version }}"
47-
if [[ "${{ github.event.inputs.state }}" == "all" ]]; then
48-
STATES="$ALL_STATES"
49-
else
50-
STATES='["${{ github.event.inputs.state }}"]'
51-
fi
52-
else
53-
# Tag push
54-
TAG="${GITHUB_REF#refs/tags/}"
55-
56-
if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
57-
# Format: v1.0.0 or v1.0.0-beta.1 - publish all states
58-
VERSION="${BASH_REMATCH[1]}"
59-
STATES="$ALL_STATES"
60-
elif [[ "$TAG" =~ ^([a-z]+)-v([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
61-
# Format: california-v1.0.0 - publish single state
62-
STATE="${BASH_REMATCH[1]}"
63-
VERSION="${BASH_REMATCH[2]}"
64-
STATES="[\"$STATE\"]"
65-
else
66-
echo "::error::Invalid tag format: $TAG. Expected v1.0.0 or state-v1.0.0"
67-
exit 1
68-
fi
69-
fi
70-
71-
echo "states=$STATES" >> $GITHUB_OUTPUT
72-
echo "version=$VERSION" >> $GITHUB_OUTPUT
73-
echo "Publishing states: $STATES at version $VERSION"
74-
7513
publish:
76-
needs: setup
7714
runs-on: ubuntu-latest
78-
permissions:
79-
contents: read
80-
id-token: write
8115
strategy:
8216
fail-fast: false
8317
matrix:
84-
state: ${{ fromJson(needs.setup.outputs.states) }}
85-
18+
state: [california, colorado]
8619
steps:
8720
- uses: actions/checkout@v4
8821

89-
- name: Setup Node.js
90-
uses: actions/setup-node@v4
22+
- uses: actions/setup-node@v4
9123
with:
9224
node-version: '24'
9325
registry-url: 'https://registry.npmjs.org'
9426

95-
- name: Upgrade npm for OIDC support
96-
run: |
97-
npm install -g npm@latest
98-
echo "npm version after upgrade:"
99-
npm --version
100-
101-
- name: Debug OIDC
102-
run: |
103-
echo "Checking OIDC token availability..."
104-
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ]; then
105-
echo "OIDC is available"
106-
echo "Token URL: $ACTIONS_ID_TOKEN_REQUEST_URL"
107-
else
108-
echo "ERROR: OIDC token request URL not set - id-token permission may be missing"
109-
fi
110-
111-
- name: Install dependencies
112-
run: npm install
27+
- run: npm install
11328

11429
- name: Build state package
11530
run: |
31+
VERSION="${GITHUB_REF#refs/tags/v}"
11632
node packages/clients/scripts/build-state-package.js \
11733
--state=${{ matrix.state }} \
118-
--version=${{ needs.setup.outputs.version }}
119-
120-
- name: Debug before publish
121-
working-directory: packages/clients/dist-packages/${{ matrix.state }}
122-
run: |
123-
echo "=== npm config ==="
124-
npm config list
125-
echo ""
126-
echo "=== .npmrc in package dir ==="
127-
cat .npmrc 2>/dev/null || echo "No .npmrc in package dir"
128-
echo ""
129-
echo "=== ~/.npmrc ==="
130-
cat ~/.npmrc 2>/dev/null || echo "No ~/.npmrc"
131-
echo ""
132-
echo "=== package.json publishConfig ==="
133-
grep -A5 '"publishConfig"' package.json || echo "No publishConfig"
134-
135-
- name: Clear token auth for OIDC
136-
run: |
137-
# Remove the authToken line from .npmrc so npm uses OIDC instead
138-
if [ -f "$NPM_CONFIG_USERCONFIG" ]; then
139-
sed -i '/:_authToken/d' "$NPM_CONFIG_USERCONFIG"
140-
echo "Cleared _authToken from $NPM_CONFIG_USERCONFIG"
141-
cat "$NPM_CONFIG_USERCONFIG"
142-
fi
34+
--version=$VERSION
14335
14436
- name: Publish to npm
14537
working-directory: packages/clients/dist-packages/${{ matrix.state }}
146-
run: npm publish --access public --provenance
147-
env:
148-
NPM_CONFIG_PROVENANCE: true
149-
NODE_AUTH_TOKEN: ''
150-
151-
summary:
152-
needs: [setup, publish]
153-
runs-on: ubuntu-latest
154-
if: always()
155-
steps:
156-
- name: Summary
157-
run: |
158-
echo "## Published Packages" >> $GITHUB_STEP_SUMMARY
159-
echo "" >> $GITHUB_STEP_SUMMARY
160-
echo "Version: ${{ needs.setup.outputs.version }}" >> $GITHUB_STEP_SUMMARY
161-
echo "" >> $GITHUB_STEP_SUMMARY
162-
echo "States:" >> $GITHUB_STEP_SUMMARY
163-
for state in $(echo '${{ needs.setup.outputs.states }}' | jq -r '.[]'); do
164-
echo "- @codeforamerica/safety-net-${state}@${{ needs.setup.outputs.version }}" >> $GITHUB_STEP_SUMMARY
165-
done
38+
run: npm publish

0 commit comments

Comments
 (0)