Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/aform 3754 add script to publish package #46

Merged
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
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