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

ci: sync workflows from central-workflows #91

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .github/workflows/dockerhub-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ name: Publish Docker image
on:
push:
branches: [ "main" ]
release:
types: [published]

jobs:
push_to_registry:
Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
with:
subject-name: docker.io/tazamaorg/${{ env.REPO_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: false
push-to-registry: true

- name: Send Slack Notification
env:
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
properties:
milestone_number:
type: string
workflow_dispatch:

jobs:
release:
Expand Down Expand Up @@ -42,32 +41,33 @@ jobs:
if: ${{ steps.release-label.outputs.level != null }}
with:
semver_only: true

- name: Get Last Merged PR
id: get_merged_pr
uses: actions-ecosystem/action-get-merged-pull-request@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

# Determine the release type (major, minor, patch) based on Last Merged PR Title
- name: Determine Release Type from PR Title
# Determine the release type (major, minor, patch) based on commit messages
- name: Determine Release Type
id: determine_release
run: |
PR_TITLE="${{ steps.get_merged_pr.outputs.title }}"
echo "PR Title: $PR_TITLE"

RELEASE_TYPE="patch" # Default release type
if echo "$PR_TITLE" | grep -q "^BREAKING CHANGE:"; then
PREV_VERSION=$(git describe --abbrev=0 --tags)
echo "Previous Version: $PREV_VERSION"

COMMIT_MESSAGES=$(git log $PREV_VERSION^..HEAD --format=%B)
echo "Commit Messages: $COMMIT_MESSAGES"

# Determine release type based on commit messages and labels
RELEASE_TYPE="patch" # Default to patch

if echo "$COMMIT_MESSAGES" | grep -q -e "BREAKING CHANGE:"; then
RELEASE_TYPE="major"
elif echo "$PR_TITLE" | grep -q "^feat!:"; then
elif echo "$COMMIT_MESSAGES" | grep -q -e "feat!:"; then
RELEASE_TYPE="major"
elif echo "$PR_TITLE" | grep -q "^feat:"; then
elif echo "$COMMIT_MESSAGES" | grep -q -e "feat:"; then
RELEASE_TYPE="minor"
else
elif echo "$COMMIT_MESSAGES" | grep -q -e "feat:" && (echo "$COMMIT_MESSAGES" | grep -q -e "fix:" || echo "$COMMIT_MESSAGES" | grep -q -e "enhancement:" || echo "$COMMIT_MESSAGES" | grep -q -e "docs:" || echo "$COMMIT_MESSAGES" | grep -q -e "refactor:" || echo "$COMMIT_MESSAGES" | grep -q -e "chore:"); then
RELEASE_TYPE="minor"
elif echo "$COMMIT_MESSAGES" | grep -q -e "fix:" -e "enhancement:" -e "docs:" -e "refactor:" -e "chore:" -e "build:" -e "ci:" -e "perf:" -e "style:" -e "test:" -e "chore(deps):" -e "chore(deps-dev):"; then
RELEASE_TYPE="patch"
fi

echo "Determined Release Type: $RELEASE_TYPE"
echo "Release Type: $RELEASE_TYPE"
echo "::set-output name=release_type::$RELEASE_TYPE"

# Bump the version based on the determined release type
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/validate-package.json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Validate package.json

Check notice

Code scanning / Checkov (reported by Codacy)

Ensure top-level permissions are not set to write-all Note

Ensure top-level permissions are not set to write-all

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
validate-package-json:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Validate package.json
id: validate-package
run: |
# Check if package.json exists
if [ ! -f package.json ]; then
echo "package.json not found!"
exit 1
fi

# Validate the required fields
REQUIRED_NAME="Tazama"
REQUIRED_EMAIL="[email protected]"
REQUIRED_URL="tazama.org"

NAME=$(jq -r '.name' package.json)
EMAIL=$(jq -r '.author.email' package.json)
URL=$(jq -r '.author.url' package.json)

if [ "$NAME" != "$REQUIRED_NAME" ]; then
echo "Error: 'name' field in package.json should be '$REQUIRED_NAME', but found '$NAME'"
exit 1
fi

if [ "$EMAIL" != "$REQUIRED_EMAIL" ]; then
echo "Error: 'email' field in package.json should be '$REQUIRED_EMAIL', but found '$EMAIL'"
exit 1
fi

if [ "$URL" != "$REQUIRED_URL" ]; then
echo "Error: 'url' field in package.json should be '$REQUIRED_URL', but found '$URL'"
exit 1
fi

echo "package.json validation successful!"

- name: Output validation result
run: echo "Validation completed successfully!"
Loading