Skip to content

Commit

Permalink
chore: workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 6, 2023
1 parent 7915bb4 commit c53b452
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 112 deletions.
12 changes: 12 additions & 0 deletions .github/configs/branch_label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 1
labels:
- label: "major"
branch: "^release/.*"
- label: "feature"
branch: "^feature/.*"
- label: "minor"
branch: "^feature/.*"
- label: "fix"
branch: "^fix/.*"
- label: "patch"
branch: "^fix/.*"
41 changes: 41 additions & 0 deletions .github/configs/configuration_repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature", "minor", "major"],
"exclude_labels": ["fix", "patch"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix", "patch"],
"exclude_labels": ["feature", "minor", "major"]
},
{
"title": "## 🐛 Wiki",
"labels": ["wiki"]
},
{
"title": "## 🐛 Test",
"labels": ["test"],
"exclude_labels": ["feature", "fix", "minor", "patch", "major"]
},
{
"title": "## 🧪 Github",
"labels": ["github"]
},
{
"title": "## 💬 Other",
"labels": ["other"]
},
{
"title": "## 📦 Dependencies",
"labels": ["dependencies"]
}
],
"sort": "ASC",
"template": "${{CHANGELOG}}",
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
"empty_template": "- no changes",
"max_pull_requests": 1000,
"max_back_track_time_days": 1000
}
32 changes: 32 additions & 0 deletions .github/configs/files_label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 1
labels:
- label: "github"
files:
- ".github/.*"
- label: "git"
files:
- ".gitignore"
- ".gitattributes"
- label: "wiki"
files:
- "README.md"
- label: "dependencies"
files:
- "pom.xml"
- label: "feature"
files:
- "src/*"
- label: "minor"
files:
- "src/*"
- label: "feature"
files:
- "Dockerfile"
- "setting.xml"
- label: "minor"
files:
- "Dockerfile"
- "setting.xml"
- label: "test"
files:
- "tests/*"
68 changes: 68 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# https://github.com/marketplace/actions/release-changelog-builder
name: 'CI'
on:
repository_dispatch:
types: [release-notes]

concurrency:
group: ${{ github.event.pull_request.number }}-ci
cancel-in-progress: true

jobs:
release-notes:
if: github.event.client_payload.auto_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Latest Release Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "latest_release_tag=$(curl -sL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/releases/latest | jq -r '.tag_name')" >> $GITHUB_ENV
echo "currentTag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v2
with:
configuration: ".github/configs/configuration_repo.json"
fromTag: ${{env.latest_release_tag}}
toTag: ${{env.currentTag}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{steps.github_release.outputs.changelog}}
tag_name: ${{env.currentTag}}
- name: Artifact Information
id: artifact_information
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
echo "archive_download_url=$(curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/actions/artifacts | jq -r '.artifacts[0].archive_download_url')" >> $GITHUB_ENV
- name: Download Artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
${{ env.archive_download_url }} -o ${{ github.event.client_payload.artifact }}.zip
- name: Upload Assets to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.event.client_payload.artifact }}.zip
tag: ${{env.currentTag}}
55 changes: 55 additions & 0 deletions .github/workflows/label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# https://github.com/marketplace/actions/pr-labeler-based-on-multiple-rules
name: "Pull Request Labeler"
on:
pull_request:
types:
- reopened
- opened


jobs:
branch-label:
runs-on: ubuntu-latest
steps:
- name: Create Labels Based Branch
uses: srvaroa/[email protected]
with:
config_path: ".github/configs/branch_label.yml"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
files-labels:
needs: branch-label
runs-on: ubuntu-latest
steps:
- name: Set Branch labels
run: |
cat <<EOF >> pr_labels.txt
patch
minor
major
EOF
- name: Get PR Labels
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/pulls/${{github.event.pull_request.number}} | jq -r '.labels[] | .name' > labels.txt
- name: Decide if to trigger Files Labels
id: trigger
run: |
comm -12 <(cat labels.txt | sort) <(cat pr_labels.txt | sort)
if [[ $(comm -12 <(cat labels.txt | sort) <(cat pr_labels.txt | sort)) ]]; then
echo "trigger_files_labels=true" >> "$GITHUB_ENV"
else
echo "trigger_files_labels=false" >> "$GITHUB_ENV"
fi
- name: Create Labels Based Files
if: env.trigger_files_labels != 'true'
uses: srvaroa/[email protected]
with:
config_path: ".github/configs/files_label.yml"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
88 changes: 0 additions & 88 deletions .github/workflows/maven-publish.yml

This file was deleted.

Loading

0 comments on commit c53b452

Please sign in to comment.