Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build and test

on:
pull_request:
branches:
- '*'

jobs:
build-and-test:
runs-on: windows-latest # ubuntu throws error on build
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: npm i

- name: Build
run: npm run build

- name: Test
run: npm run test
97 changes: 97 additions & 0 deletions .github/workflows/tag-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Tag, Release, & Publish

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Extract Changelog Entry
id: extract_changelog
shell: pwsh
run: |

$version = (Get-Content package.json | ConvertFrom-Json).version
Write-Host "Version: $version"

# Set the path to your changelog file
$changelogFile = "CHANGELOG.md"

# Ensure the changelog file exists and read lines
if (Test-Path $changelogFile) {
$lines = Get-Content $changelogFile
$changelogContent = ""
$isCapturing = $false

# Capture changelog content for the specified version
foreach ($line in $lines) {
# Check if we match the version header
if ($line -match "# \[$($version)\]") {
$isCapturing = $true
continue
}
if ($isCapturing) {
$changelogContent += "$line`n"
# Stop when another version header is found (match format like '# [1.0.0]')
if ($line -match "# \[\d+\.\d+\.\d+\]") {
break
}
}
}

# Clean up changelog content
if ($changelogContent) {
$changelogContent = $changelogContent.Trim()
$changelogContent = $changelogContent -replace "# \[\d+\.\d+\.\d+\] - \d{4}-\d{2}-\d{2}\s*", ""

Write-Host "Changelog entry for version $version found!"
Write-Host "Changelog content: $changelogContent"

# Store the changelog content in the GITHUB_ENV variable
echo "changelog_content=$changelogContent" >> $env:GITHUB_OUTPUT
} else {
Write-Host "No changelog entry found for version $version."
exit 1
}
} else {
Write-Host "Changelog file not found."
exit 1
}

- name: Tag
id: autotagger
if: steps.check_changes.outputs.uncommitted == 'false'
uses: Klemensas/action-autotag@stable
with:
tag_message: ${{ steps.extract_changelog.outputs.changelog_content }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release
id: create_release
if: steps.check_changes.outputs.uncommitted == 'false' && steps.autotagger.outputs.tagname != ''
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
release_name: ${{ steps.autotagger.outputs.tagname }}
body: ${{ steps.extract_changelog.outputs.changelog_content }}
draft: false

- name: Publish to npm
if: steps.check_changes.outputs.uncommitted == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish --dry-run --access public
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to the ordercloud-javascript-sdk will be documented in this
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [11.0.1] - 2025-03-05
- Introduce github action workflows

# [11.0.0] - 2025-03-04
- Bring SDK up to date with API v1.0.384
- This version includes a breaking change to the return type of `Cart.ListEligiblePromotions` and `Orders.ListEligiblePromotions`. See migration guide for more details.
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ Assuming you or a contributor followed the instructions for [submitting a pull r
1. Verify the version has been bumped and adheres to [semantic versioning](https://semver.org/)
2. Verify the [changelog](./CHANGELOG.md) has been updated
3. Merge the pull request
4. Create a [new release on github](https://github.com/ordercloud-api/ordercloud-javascript-sdk/releases/new) with a new git tag.
5. Run `npm publish --dry-run` for a preview, or `npm publish`.
6. Have a beer! 🍻
4. The Tag, Release, & Publish workflow will take care of creating a git tag and releasing to npm for you.
Loading