release #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
workflow_dispatch: | |
inputs: | |
component: | |
type: choice | |
description: 'Which components to release?' | |
options: | |
- client | |
- server | |
- both | |
default: 'both' | |
required: true | |
level: | |
type: choice | |
description: 'Version level increment' | |
options: | |
- patch | |
- minor | |
- major | |
default: 'patch' | |
required: true | |
publish: | |
type: boolean | |
description: 'Publish packages' | |
default: false | |
required: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
version: | |
name: get release version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.next-version.outputs.new_version }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: get latest tag | |
uses: mgor/action-get-latest-tag@v1.1.0 | |
id: get-latest-tag | |
with: | |
semver_only: true | |
initial_version: '0.0.0' | |
with_initial_version: true | |
- name: next version | |
uses: mgor/action-bump-semver@v1.0.0 | |
id: next-version | |
with: | |
current_version: ${{ steps.get-latest-tag.outputs.tag }} | |
level: ${{ github.event.inputs.level }} | |
- name: version | |
run: | | |
echo "current version is ${{ steps.get-latest-tag.outputs.tag }}" | |
echo "next version is ${{ steps.next-version.outputs.new_version }}" | |
server: | |
name: build and publish server | |
runs-on: ubuntu-latest | |
needs: [version] | |
if: ${{ github.event.inputs.component == 'both' || github.event.inputs.component == 'server' }} | |
defaults: | |
run: | |
working-directory: ./grizzly-ls | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: create temporary release tag | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a "${{ needs.version.outputs.version }}" -m "Release ${{ needs.version.outputs.version }}" | |
- name: install dependencies | |
run: | | |
python -m pip install .[ci] | |
- name: build | |
run: | | |
python -m build | |
- name: 'publish (${{ github.event.inputs.publish }})' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
TWINE_NON_INTERACTIVE: true | |
VERSION: ${{ needs.version.outputs.version }} | |
run: | | |
if [[ "${{ github.event.inputs.publish }}" == "true" ]]; then | |
python -m twine upload dist/grizzly?loadtester?ls-${VERSION#v}* | |
else | |
ls -l dist/grizzly?loadtester?ls-${VERSION#v}* | |
fi | |
client: | |
name: build and publish client | |
runs-on: ubuntu-latest | |
needs: [version] | |
if: ${{ github.event.inputs.component == 'both' || github.event.inputs.component == 'client' }} | |
defaults: | |
run: | |
working-directory: ./client/vscode | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
cache-dependency-path: './client/vscode/package-lock.json' | |
- name: bump version | |
env: | |
VERSION: ${{ needs.version.outputs.version }} | |
run: | | |
npm version "${VERSION#v}" | |
- name: install dependencies | |
run: | | |
npm install | |
npm install -g @vscode/vsce | |
- name: build | |
run: | | |
vsce package | |
- name: publish (${{ github.event.inputs.publish }}) | |
env: | |
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }} | |
VERSION: ${{ needs.version.outputs.version }} | |
run: | | |
if [[ "${{ github.event.inputs.publish }}" == "true" ]]; then | |
vsce publish -p $VSCE_TOKEN | |
else | |
ls -l grizzly-loadtester-vscode-${VERSION#v}.vsix | |
unzip -t grizzly-loadtester-vscode-${VERSION#v}.vsix || true | |
fi | |
tag-release: | |
name: create and push release tag | |
runs-on: ubuntu-latest | |
needs: [version, server, client] | |
if: ${{ github.event.inputs.publish == 'true' }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: create and push release tag | |
run: | | |
set -e | |
tag="${{ needs.version.outputs.version }}" | |
message="Release ${tag}" | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a "${tag}" -m "${message}" | |
git push origin "${tag}" |