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

[INTER-166] Setup shared workflows and semantic-release #168

Merged
merged 11 commits into from
Oct 30, 2023
9 changes: 0 additions & 9 deletions .github/actions/publish-release/action.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/actions/publish-release/index.js

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/analyze-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Analyze Commit Messages
on:
pull_request:

permissions:
pull-requests: write
contents: write
jobs:
analyze-commits:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/analyze-commits.yml@v1
73 changes: 0 additions & 73 deletions .github/workflows/build.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: ci
on:
push:
branches-ignore:
- main
paths-ignore:
- '**.md'

jobs:
build-and-check:
name: Build project and run CI checks
uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1
12 changes: 12 additions & 0 deletions .github/workflows/coverage-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Check coverage for PR

on:
pull_request:

jobs:
run-tests-check-coverage:
name: Run tests & check coverage
permissions:
checks: write
pull-requests: write
uses: fingerprintjs/dx-team-toolkit/.github/workflows/coverage-diff.yml@v1
15 changes: 15 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Generate docs and coverage report

on:
push:
branches:
- main

jobs:
generate-docs-and-coverage:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1
with:
skip-docs-step: true
prepare-gh-pages-commands: |
mv coverage/lcov-report ./gh-pages/coverage
32 changes: 0 additions & 32 deletions .github/workflows/publish-release.yml

This file was deleted.

124 changes: 10 additions & 114 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,117 +1,13 @@
name: Release

name: release
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Create a pre-release'
default: 'false'
required: false
type: boolean
version_bump:
description: 'A type of version bump'
default: 'patch'
required: true
type: choice
options:
- major
- minor
- patch
push:
branches:
- main
- test

jobs:
release:
name: Release Azure integration distribution
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

if: github.ref == 'refs/heads/develop'

steps:
- name: Checkout develop branch
uses: actions/checkout@v3
with:
ref: develop
fetch-depth: 0

- name: Install node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'

- name: Set git settings
uses: fregante/setup-git-user@v1

- name: Install dependencies
run: yarn install

- name: Lint
run: yarn lint

- name: Run tests
run: yarn test

- name: Disable version tags
run: yarn config set version-git-tag false

- name: Bump version
run: yarn version --${{ github.event.inputs.version_bump }}

- name: Build functions
run: yarn build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
FPCDN: fpcdn.io
INGRESS_API: api.fpjs.io
IS_RELEASE_BUILD: true

- name: Get new version of function
id: new_version
uses: notiz-dev/[email protected]
with:
path: 'package.json'
prop_path: 'version'

- name: Prepare a package
run: |
cd dist
zip -r package.zip *
mv package.zip ../
cd ../
cp package.zip v${{steps.new_version.outputs.prop}}.zip

- name: Commit and push new version of lambda
run: |
git commit package.json -m "chore: release v${{steps.new_version.outputs.prop}}"
git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git tag -a "v${{steps.new_version.outputs.prop}}" -m "v${{steps.new_version.outputs.prop}}"
git push --tags "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"

## Prepare a release
- name: Create a Github release
uses: ncipollo/release-action@v1
with:
tag: v${{steps.new_version.outputs.prop}}
name: v${{steps.new_version.outputs.prop}}
draft: true
prerelease: ${{ github.event.inputs.prerelease }}
artifacts: v${{steps.new_version.outputs.prop}}.zip,package.zip
artifactContentType: 'application/zip'
generateReleaseNotes: true

- name: Create Pull Request from develop to main
id: create_pr
uses: devops-infra/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: develop
target_branch: main
title: v${{ steps.new_version.outputs.prop }}
body: New version of scripts v${{ steps.new_version.outputs.prop }}
label: release

- name: Check PR outputs
if: ${{ steps.create_pr.outputs.url }}
run: echo "Pull Request URL - ${{ steps.create_pr.outputs.url }}"
build-and-release:
name: 'Build project, run CI checks and publish new release'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-typescript-project.yml@v1
secrets:
GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
15 changes: 15 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

containsref() { if [[ $2 =~ $1 ]]; then echo 1; else echo 0; fi }

push_command=$(ps -ocommand= -p $PPID | cut -d' ' -f 4)
protected_branch='main'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
is_push_to_main_origin=$(containsref '[email protected]:/?fingerprintjs/' "$push_command")

# Block pushes only to protected branch in main repository
if [ $is_push_to_main_origin = 1 ] && [ "$protected_branch" = "$current_branch" ]; then
echo "You are on the $protected_branch branch, push blocked."
exit 1 # push will not execute
fi
Loading
Loading