Skip to content

Commit

Permalink
Merge pull request #46 from episerver/feature/AFORM-3754-Add-script-t…
Browse files Browse the repository at this point in the history
…o-publish-package

Feature/aform 3754 add script to publish package
  • Loading branch information
hungoptimizely authored Dec 6, 2023
2 parents 5ce4043 + eff8752 commit a25fe1a
Show file tree
Hide file tree
Showing 141 changed files with 1,477 additions and 1,385 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ name: Optimizely Headless Form CI

on:
push:
branches: [ "develop" ]
branches:
- master
- develop
- feature/*
- bugfix/*
pull_request:
branches: [ "develop" ]

jobs:
build:
permissions:
contents: write
packages: write
id-token: write

runs-on: ubuntu-latest
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build, test, and publish
runs-on: windows-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
strategy:
matrix:
node-version: [16.x]
Expand All @@ -34,3 +47,11 @@ jobs:

- name: Run unit test
run: npm test

- name: Apply Versioning
run: |
echo "running on branch" ${{env.BRANCH_NAME}}
${{ github.workspace}}/build/get-versionSuffix.ps1 ${{env.BRANCH_NAME}} ${{github.RUN_NUMBER}}
- name: Publish
run: npm run publish
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@episerver:registry=https://npm.pkg.github.com/episerver/
always-auth=true
//npm.pkg.github.com/episerver/:_authToken=${NPM_AUTH_TOKEN}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"jest.rootPath": "src/@optimizely/forms-sdk",
"jest.rootPath": "src/@episerver/forms-sdk",
"jest.jestCommandLine": "npm run test --",
}
Binary file modified README.md
Binary file not shown.
60 changes: 60 additions & 0 deletions build/get-versionSuffix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Param([string]$branchName, [Int]$buildCounter)

if (!$branchName -or !$buildCounter) {
Write-Error "`$branchName and `$buildCounter parameters must be supplied"
exit 1
}

switch -wildcard ($branchName) {
"master" {
$preReleaseInfo = ""
}
"develop" {
$preReleaseInfo = "-inte-{0:D6}"
}
"hotfix/*" {
$preReleaseInfo = "-ci-{0:D6}"
}
"bugfix/*" {
$preReleaseInfo = "-ci-{0:D6}"
}
"release/*" {
$preReleaseInfo = "-pre-{0:D6}"
}
"feature/*" {
$isMatch = $branchName -match ".*/([A-Z]+-[\d]+)-"
if ($isMatch -eq $TRUE) {
$feature = $Matches[1]
$preReleaseInfo = "-feature-$feature-{0:D6}"
}
else {
$preReleaseInfo = "-feature-{0:D6}"
}
}
default { $preReleaseInfo = "-ci-{0:D6}" }
}
<# update version for forms-sdk #>
$json = (Get-Content src/@episerver/forms-sdk/package.json -Raw)

$versionSuffix = "$preReleaseInfo" -f $buildCounter
$version = (Get-Content src/@episerver/forms-sdk/package.json) -join "`n" | ConvertFrom-Json | Select-Object -ExpandProperty "version"
Write-Output "Version read from package.json: $version"
Write-Output "Version suffix: $versionSuffix"

$fullVersion = "$version$versionSuffix"
Write-Output "Package version: $fullVersion"

$json -replace $version,$fullVersion | Set-Content -Path src/@episerver/forms-sdk/package.json

<# update version for forms-react #>
$json = (Get-Content src/@episerver/forms-react/package.json -Raw)

$versionSuffix = "$preReleaseInfo" -f $buildCounter
$version = (Get-Content src/@episerver/forms-react/package.json) -join "`n" | ConvertFrom-Json | Select-Object -ExpandProperty "version"
Write-Output "Version read from package.json: $version"
Write-Output "Version suffix: $versionSuffix"

$fullVersion = "$version$versionSuffix"
Write-Output "Package version: $fullVersion"

$json -replace $version,$fullVersion | Set-Content -Path src/@episerver/forms-react/package.json
Loading

0 comments on commit a25fe1a

Please sign in to comment.