Skip to content

Commit 62f394e

Browse files
authored
Merge pull request #130 from erincdustin/10.0.4_draft
11.0.1 github actions workflows
2 parents 9747645 + 7dcdaea commit 62f394e

File tree

7 files changed

+291
-167
lines changed

7 files changed

+291
-167
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: windows-latest # ubuntu throws error on build
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
- name: Install Dependencies
18+
run: npm i
19+
20+
- name: Build
21+
run: npm run build
22+
23+
- name: Test
24+
run: npm run test
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Tag, Release, & Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
19+
- name: Extract Changelog Entry
20+
id: extract_changelog
21+
shell: pwsh
22+
run: |
23+
24+
$version = (Get-Content package.json | ConvertFrom-Json).version
25+
Write-Host "Version: $version"
26+
27+
# Set the path to your changelog file
28+
$changelogFile = "CHANGELOG.md"
29+
30+
# Ensure the changelog file exists and read lines
31+
if (Test-Path $changelogFile) {
32+
$lines = Get-Content $changelogFile
33+
$changelogContent = ""
34+
$isCapturing = $false
35+
36+
# Capture changelog content for the specified version
37+
foreach ($line in $lines) {
38+
# Check if we match the version header
39+
if ($line -match "# \[$($version)\]") {
40+
$isCapturing = $true
41+
continue
42+
}
43+
if ($isCapturing) {
44+
$changelogContent += "$line`n"
45+
# Stop when another version header is found (match format like '# [1.0.0]')
46+
if ($line -match "# \[\d+\.\d+\.\d+\]") {
47+
break
48+
}
49+
}
50+
}
51+
52+
# Clean up changelog content
53+
if ($changelogContent) {
54+
$changelogContent = $changelogContent.Trim()
55+
$changelogContent = $changelogContent -replace "# \[\d+\.\d+\.\d+\] - \d{4}-\d{2}-\d{2}\s*", ""
56+
57+
Write-Host "Changelog entry for version $version found!"
58+
Write-Host "Changelog content: $changelogContent"
59+
60+
# Store the changelog content in the GITHUB_ENV variable
61+
echo "changelog_content=$changelogContent" >> $env:GITHUB_OUTPUT
62+
} else {
63+
Write-Host "No changelog entry found for version $version."
64+
exit 1
65+
}
66+
} else {
67+
Write-Host "Changelog file not found."
68+
exit 1
69+
}
70+
71+
- name: Tag
72+
id: autotagger
73+
if: steps.check_changes.outputs.uncommitted == 'false'
74+
uses: Klemensas/action-autotag@stable
75+
with:
76+
tag_message: ${{ steps.extract_changelog.outputs.changelog_content }}
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Release
81+
id: create_release
82+
if: steps.check_changes.outputs.uncommitted == 'false' && steps.autotagger.outputs.tagname != ''
83+
uses: actions/create-release@v1.0.0
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
tag_name: ${{ steps.autotagger.outputs.tagname }}
88+
release_name: ${{ steps.autotagger.outputs.tagname }}
89+
body: ${{ steps.extract_changelog.outputs.changelog_content }}
90+
draft: false
91+
92+
- name: Publish to npm
93+
if: steps.check_changes.outputs.uncommitted == 'false'
94+
env:
95+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
96+
run: |
97+
npm publish --dry-run --access public

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to the ordercloud-javascript-sdk will be documented in this
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
# [11.0.1] - 2025-03-05
9+
- Introduce github action workflows
10+
811
# [11.0.0] - 2025-03-04
912
- Bring SDK up to date with API v1.0.384
1013
- This version includes a breaking change to the return type of `Cart.ListEligiblePromotions` and `Orders.ListEligiblePromotions`. See migration guide for more details.

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,4 @@ Assuming you or a contributor followed the instructions for [submitting a pull r
4545
1. Verify the version has been bumped and adheres to [semantic versioning](https://semver.org/)
4646
2. Verify the [changelog](./CHANGELOG.md) has been updated
4747
3. Merge the pull request
48-
4. Create a [new release on github](https://github.com/ordercloud-api/ordercloud-javascript-sdk/releases/new) with a new git tag.
49-
5. Run `npm publish --dry-run` for a preview, or `npm publish`.
50-
6. Have a beer! 🍻
48+
4. The Tag, Release, & Publish workflow will take care of creating a git tag and releasing to npm for you.

0 commit comments

Comments
 (0)