Skip to content

Defect/fix release publish job #18

Defect/fix release publish job

Defect/fix release publish job #18

Workflow file for this run

name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
push:
tags:
- '*'
jobs:
package:
name: Package
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Tool Versions
run: npm --version
- name: Checkout
uses: actions/checkout@v4
- name: npm Package
run: |
cd WebHelpDocs
npm pack
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: WebHelpDocs
path: ./WebHelpDocs/*.tgz
publish:
name: Publish
if: ${{ (endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/')) || github.event.pull_request.merged ) }}
needs:
- package
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
#https://github.com/actions/runner/issues/2033#issuecomment-1598547465
options: --user 1001
steps:
- name: Tool Versions
run: npm --version
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@tektronix'
- name: Checkout
uses: actions/checkout@v4
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
name: WebHelpDocs
- name: publish pack
run: |
npm publish *.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
name: Release
if: ${{ (endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/')) || github.event.pull_request.merged ) }}
needs:
- publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Tagged Version
id: lasttag
run: |
COMMIT="${{github.sha}}"
if ${{contains(github.head_ref, 'release/')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(npm pkg get version)"
echo "Extracted Version: $V"
V="$(echo v"$V" | sed 's/\"//g')"
echo "Cleaned up Version: $V"
fi
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
echo "RC Version: $V"
fi
CL=${V#v}
CL=${CL%-*}
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
- name: Get Changelog for this Tag
id: changelog
uses: coditory/changelog-parser@v1
with:
version: ${{steps.lasttag.outputs.cl_version}}
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{steps.lasttag.outputs.version}}
body: |
## Features Requests / Bugs
If you find issues or have a feature request, please enter a [new issue on GitHub](https://github.com/tektronix/tsp-toolkit-kic-cli/issues/new).
## Installation
View the installation instructions in the [README](https://github.com/tektronix/tsp-toolkit-kic-cli/blob/main/README.md)
## Changelog
${{steps.changelog.outputs.description}}
prerelease: ${{(! github.event.pull_request.merged) || (github.event.pull_request.merged && ! contains(github.head_ref, 'release/'))}}
commit: ${{steps.lasttag.outputs.commit}}
makeLatest: true
tag: ${{steps.lasttag.outputs.version}}