Release #45
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: | |
prerelease-channel: | |
type: choice | |
description: "Prerelease channel to use (only if prerelease is selected)" | |
required: false | |
options: | |
- dev | |
- stage | |
- none | |
release-as: | |
type: choice | |
description: "Release as option to use (none, patch, minor, major)" | |
required: false | |
options: | |
- none | |
- patch | |
- minor | |
- major | |
sync_argocd: | |
description: "Sync Argo CD app after release?" | |
type: boolean | |
required: false | |
default: false | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.read_version.outputs.version }} | |
deploy-env: ${{ steps.set_env.outputs.deploy-env }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.INTOBRIDGE_GITHUB_TOKEN }} | |
- run: git fetch --prune --unshallow --tags | |
continue-on-error: true | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
- run: npm install -g standard-version | |
continue-on-error: true | |
- name: Configure committer | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Prepare release command args | |
id: release_args | |
run: | | |
STANDARD_VERSION_ARGS= | |
if [ "${{ github.event.inputs.prerelease-channel }}" != "none" ]; then | |
STANDARD_VERSION_ARGS="$STANDARD_VERSION_ARGS --prerelease=${{ github.event.inputs.prerelease-channel }}" | |
fi | |
if [ "${{ github.event.inputs.release-as }}" != "none" ]; then | |
STANDARD_VERSION_ARGS="$STANDARD_VERSION_ARGS --release-as=${{ github.event.inputs.release-as }}" | |
fi | |
echo "standard-version-args=$STANDARD_VERSION_ARGS" >> $GITHUB_OUTPUT | |
- if: ${{ github.event.inputs.prerelease-channel != 'none' }} | |
run: | | |
git tag -l | grep -vE '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)-${{ github.event.inputs.prerelease-channel }}\.(0|[1-9][0-9]*)$' | xargs git tag -d | |
- if: ${{ github.event.inputs.prerelease-channel == 'none' }} | |
run: | | |
git tag -l | grep -vE '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' | xargs git tag -d | |
- name: Release | |
run: | | |
npx standard-version ${{ steps.release_args.outputs.standard-version-args }} | |
- name: Publish tag | |
id: publish_tag | |
run: | | |
git push --follow-tags | |
echo "TAG_NAME=$(git describe HEAD --abbrev=0)" >> $GITHUB_ENV | |
- name: Set deploy environment | |
id: set_env | |
run: | | |
if [ "${{ github.event.inputs.prerelease-channel }}" != "none" ]; then | |
echo "deploy-env=${{ github.event.inputs.prerelease-channel }}" >> $GITHUB_OUTPUT | |
else | |
echo "deploy-env=prod" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Github Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.INTOBRIDGE_GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.TAG_NAME }} | |
body_path: CHANGELOG.md | |
draft: false | |
prerelease: ${{ github.event.inputs.prerelease-channel == 'none' }} | |
- id: read_version | |
run: echo "version=v$(cat VERSION)" >> $GITHUB_OUTPUT | |
build: | |
needs: release | |
uses: ./.github/workflows/build.workflow.yml | |
with: | |
version: ${{ needs.release.outputs.version }} | |
secrets: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
sync_stack: | |
needs: [release, build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger Update in Stack Repo | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.INTOBRIDGE_GITHUB_TOKEN }} | |
repository: 'seven-of-di/stack' | |
event-type: 'update-version' | |
client-payload: | | |
{ | |
"service": "ben", | |
"version": "${{ needs.release.outputs.version }}", | |
"environment": "${{ needs.release.outputs.deploy-env }}", | |
"syncArgo": ${{ github.event.inputs.sync_argocd }} | |
} |