Skip to content

Commit 98ab5eb

Browse files
author
Fabiana Severin
committed
Adding rc publishing
1 parent 88a021d commit 98ab5eb

File tree

1 file changed

+83
-7
lines changed

1 file changed

+83
-7
lines changed

.github/workflows/build-and-release.yml

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ name: Build and Release
33
on:
44
push:
55
branches: [ fabisev/artifact-publishing ]
6-
tags: [ 'v*' ]
6+
tags: [ 'v*', 'rc-*' ]
77
pull_request:
88
branches: [ main ]
9+
workflow_dispatch:
10+
inputs:
11+
test_mode:
12+
description: 'Test mode (release, rc, or none)'
13+
required: true
14+
default: 'none'
15+
type: choice
16+
options:
17+
- none
18+
- release
19+
- rc
920

1021
jobs:
1122
lint:
@@ -88,11 +99,9 @@ jobs:
8899
run: |
89100
docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x .
90101
docker run --rm unit/nodejs.${{ matrix.node-version }}x
91-
92-
93102
94103
publish:
95-
if: startsWith(github.ref, 'refs/tags/v')
104+
if: startsWith(github.ref, 'refs/tags/')
96105
runs-on: ubuntu-latest
97106
needs: [build, test]
98107
permissions:
@@ -114,10 +123,31 @@ jobs:
114123
uses: actions/setup-node@v4
115124
with:
116125
node-version: '20'
117-
registry-url: 'https://registry.npmjs.org'
118126

127+
# Handle release candidate version if needed
128+
- name: Determine version
129+
id: version
130+
run: |
131+
if [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then
132+
RC_NUMBER=${GITHUB_REF#refs/tags/rc-}
133+
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}"
134+
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
135+
echo "is_rc=true" >> $GITHUB_OUTPUT
136+
# Update package.json version to include RC suffix
137+
npm version $PACKAGE_VERSION --no-git-tag-version
138+
else
139+
echo "package_version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
140+
echo "is_rc=false" >> $GITHUB_OUTPUT
141+
fi
142+
143+
# Commented out npm publishing until token is available
119144
# - name: Publish to npm
120-
# run: npm publish aws-lambda-ric-*.tgz
145+
# run: |
146+
# if [[ "${{ steps.version.outputs.is_rc }}" == "true" ]]; then
147+
# npm publish aws-lambda-ric-*.tgz --tag rc
148+
# else
149+
# npm publish aws-lambda-ric-*.tgz
150+
# fi
121151
# env:
122152
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
123153

@@ -129,4 +159,50 @@ jobs:
129159
checksums.sha256
130160
checksums.sha512
131161
checksums.txt
132-
generate_release_notes: true
162+
prerelease: ${{ steps.version.outputs.is_rc }}
163+
name: ${{ steps.version.outputs.is_rc == 'true' && format('Release Candidate {0}', steps.version.outputs.package_version) || '' }}
164+
generate_release_notes: true
165+
166+
test-publish:
167+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_mode != 'none'
168+
runs-on: ubuntu-latest
169+
needs: [build, test]
170+
steps:
171+
- uses: actions/checkout@v4
172+
173+
- name: Download artifacts
174+
uses: actions/download-artifact@v4
175+
with:
176+
name: package-${{ needs.build.outputs.version }}
177+
178+
- name: Verify checksums
179+
run: |
180+
sha256sum -c checksums.sha256
181+
sha512sum -c checksums.sha512
182+
183+
- name: Setup Node.js
184+
uses: actions/setup-node@v4
185+
with:
186+
node-version: '20'
187+
188+
- name: Test Release Publishing
189+
if: github.event.inputs.test_mode == 'release'
190+
run: |
191+
echo "=== TESTING RELEASE PUBLISHING (DRY RUN) ==="
192+
echo "Would create a GitHub release with the following files:"
193+
ls -la aws-lambda-ric-*.tgz checksums.*
194+
echo "\nRelease would include version: ${{ needs.build.outputs.version }}"
195+
196+
- name: Test RC Publishing
197+
if: github.event.inputs.test_mode == 'rc'
198+
run: |
199+
echo "=== TESTING RC PUBLISHING (DRY RUN) ==="
200+
# Simulate RC version
201+
RC_NUMBER="1"
202+
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}"
203+
echo "Would create a GitHub pre-release with the following files:"
204+
ls -la aws-lambda-ric-*.tgz checksums.*
205+
echo "\nRelease would include version: ${PACKAGE_VERSION}"
206+
207+
# Update version for display purposes
208+
npm version ${PACKAGE_VERSION} --no-git-tag-version

0 commit comments

Comments
 (0)