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
98 changes: 98 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build and Push to Artifacts S3

on:
workflow_call:
inputs:
newVersion:
description: 'new version?'
required: true
type: string
version:
description: 'The version of the file to build and push'
required: true
type: string
hash:
description: 'The commit hash'
required: true
type: string
tag:
description: 'The tag of the image to build and push'
required: true
type: string
channel:
description: 'The channel of the image to build and push'
required: true
type: string
jobs:
Build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node 20
uses: actions/setup-node@v3
with:
cache: npm
node-version: '20'
registry-url: "https://npm.pkg.github.com"
- name: Set package.json version
run: |
if [ '${{ inputs.newVersion }}' = 'true' ]; then
echo "Setting package.json version to ${{ inputs.version }}"
npm version ${{ inputs.version }} --no-git-tag-version
else
echo "Not setting package.json version"
fi
- name: Install Packages
run: |
npm ci
# - name: Replace version number for api call
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: "'vx.y.z'"
# replace: "'${{ inputs.newVersion == 'true' && inputs.tag || format('{0}-{1}', github.ref_name, inputs.hash)}}'"
# include: 'appVersion.ts'
- name: Build App
run: |
buildSummary=$(npm run build)

IFS=""
readarray buildSummaryArray <<< "$buildSummary"

for i in ${buildSummaryArray[@]}
do
echo "$i" >> $GITHUB_STEP_SUMMARY
done
- name: Archive Output
id: package
run: |
cd dist
branch=${GITHUB_REF#refs/heads/}

if [ '${{ inputs.newVersion }}' = 'true' ]; then
filename=essentials-demo-app-${{ inputs.tag }}-${{ inputs.hash }}.zip
else
filename=essentials-demo-app-${branch//\//-}-${{ inputs.hash }}.zip
fi

zip -r ../$filename .
echo "filename=${filename}" >> $GITHUB_OUTPUT
- name: Get release notes
if: inputs.newVersion == 'true'
uses: actions/download-artifact@v4
with:
name: change-log
- name: Create Release
id: create_release
if: inputs.newVersion == 'true'
uses: ncipollo/release-action@v1
with:
artifacts: './${{ steps.package.outputs.filename }}'
bodyFile: ./CHANGELOG.md
prerelease: ${{ inputs.channel != '' }}
tag: ${{ inputs.tag }}
commit: ${{ github.sha }}
allowUpdates: true
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci

on:
push:
branches:
- '**'
jobs:
get_version:
uses: ./.github/workflows/get-version.yaml
secrets: inherit
build_and_push:
uses: ./.github/workflows/build.yaml
secrets: inherit
needs: get_version
with:
newVersion: ${{ needs.get_version.outputs.newVersion }}
version: ${{ needs.get_version.outputs.version }}
hash: ${{ needs.get_version.outputs.hash }}
tag: ${{ needs.get_version.outputs.tag }}
channel: ${{ needs.get_version.outputs.channel }}
# deploy:
# uses: ./.github/workflows/deploy.yaml
# secrets: inherit
# needs: [get_version, build_and_push]
# if: needs.get_version.outputs.newVersion == 'true'
# with:
# version: ${{ needs.get_version.outputs.version }}
# hash: ${{ needs.get_version.outputs.hash }}
# tag: ${{ needs.get_version.outputs.tag }}
# channel: ${{ needs.get_version.outputs.channel }}
102 changes: 102 additions & 0 deletions .github/workflows/get-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Get Version

on:
workflow_call:
outputs:
version:
description: 'The version of the workflow'
value: ${{ jobs.get_version.outputs.version }}
tag:
description: 'The tag of the workflow'
value: ${{ jobs.get_version.outputs.tag }}
newVersion:
description: 'Was a new version generated?'
value: ${{ jobs.get_version.outputs.newVersion }}
type:
description: 'The type of version bump'
value: ${{ jobs.get_version.outputs.type }}
channel:
description: 'The channel of the workflow'
value: ${{ jobs.get_version.outputs.channel }}
hash:
description: 'The short SHA of the workflow'
value: ${{ jobs.get_version.outputs.hash }}
jobs:
get_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
hash: ${{ steps.get_version.outputs.hash }}
channel: ${{ steps.get_version.outputs.channel }}
newVersion: ${{ steps.get_version.outputs.newVersion }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4 # v4
with:
cache: npm
node-version: lts/*
registry-url: https://npm.pkg.github.com
scope: "@pepperdash-products"
- name: Get branch name
id: get_branch
run: |
branch=${GITHUB_REF#refs/heads/}
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "prerelease=${branch//\//-}" >> $GITHUB_OUTPUT
env:
GITHUB_REF: ${{ github.ref }}
- name: Replace branch name in .releaserc.json
if: steps.get_branch.outputs.branch != 'main'
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'replace-me-feature-branch'
replace: '${{ steps.get_branch.outputs.branch }}'
include: '.releaserc.json'
- name: Replace prerelease name in .releaserc.json
if: steps.get_branch.outputs.branch != 'main'
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'replace-me-prerelease'
replace: '${{ steps.get_branch.outputs.prerelease }}'
include: '.releaserc.json'
- name: Get version number
id: get_version
run: |
npx --package=semantic-release \
--package=@semantic-release/commit-analyzer \
--package=@semantic-release/release-notes-generator \
--package=@semantic-release/changelog \
--package=@semantic-release/exec \
--package=conventional-changelog-conventionalcommits@5 \
-- semantic-release
echo "hash=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print summary if no new version
if: steps.get_version.outputs.newVersion != 'true'
run: |
branch=${GITHUB_REF#refs/heads/}
echo "# Essentials Demo App Summary" >> $GITHUB_STEP_SUMMARY
echo "No new version generated" >> $GITHUB_STEP_SUMMARY
echo "To upload the build from this run, use the following values in the deploy-manual manual action:" >> $GITHUB_STEP_SUMMARY
echo "version: ${branch//\//-}" >> $GITHUB_STEP_SUMMARY
echo "hash: ${{ steps.get_version.outputs.hash }}" >> $GITHUB_STEP_SUMMARY
- name: Upload release notes
if: steps.get_version.outputs.newVersion == 'true'
uses: actions/upload-artifact@v4
with:
name: change-log
path: CHANGELOG.md
- name: Print results
if: steps.get_version.outputs.newVersion == 'true'
run: |
echo "# Essentials Demo App Summary" >> $GITHUB_STEP_SUMMARY

echo "Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Tag: ${{ steps.get_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "New Version: ${{ steps.get_version.outputs.newVersion }}" >> $GITHUB_STEP_SUMMARY
echo "Channel: ${{ steps.get_version.outputs.channel }}" >> $GITHUB_STEP_SUMMARY
echo "Type: ${{ steps.get_version.outputs.type }}" >> $GITHUB_STEP_SUMMARY
echo "Short SHA: ${{ steps.get_version.outputs.hash }}" >> $GITHUB_STEP_SUMMARY
53 changes: 53 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "scope": "force-patch", "release": "patch" },
{ "scope": "no-release", "release": false }
]
}
],
["@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig":{
"types": [
{"type": "feat", "section": "Features"},
{"type": "fix", "section": "Bug Fixes"},
{"type": "chore", "hidden": true},
{"type": "docs", "hidden": true},
{"type": "style", "hidden": true},
{"type": "refactor", "hidden": true},
{"type": "perf", "hidden": true},
{"type": "test", "hidden": true}
]
}
}
],
["@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
"analyzeCommitsCmd": "echo \"${releases}\" >> $GITHUB_STEP_SUMMARY && echo \"version ${lastRelease.version} tag ${lastRelease.gitTag} type ${lastRelease.type} channel ${lastRelease.channel}\" >> $GITHUB_STEP_SUMMARY",
"verifyReleaseCmd": "echo \"newVersion=true\" >> $GITHUB_OUTPUT",
"publishCmd": "echo \"version=${nextRelease.version}\" >> $GITHUB_OUTPUT && echo \"tag=${nextRelease.gitTag}\" >> $GITHUB_OUTPUT && echo \"type=${nextRelease.type}\" >> $GITHUB_OUTPUT && echo \"channel=${nextRelease.channel}\" >> $GITHUB_OUTPUT"
}
]
],
"pkgRoot": "dist",
"branches": [
"main",
{
"name": "replace-me-feature-branch",
"prerelease": "replace-me-prerelease",
"channel": "replace-me-prerelease"
}
]
}
Loading