Skip to content

Commit

Permalink
Add gitversion and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Facundo Santillo Alarcon committed Oct 27, 2024
1 parent b74c05f commit 5beb369
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI Pipeline

on:
workflow_dispatch:
pull_request:
branches:
- main
- release/*

jobs:
setup:
runs-on: ubuntu-latest

env:
GitToolVersion: 6.0.3

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history to get full git version details

# Install GitVersion tool
- name: Install GitVersion
uses: gittools/actions/setup@v0
with:
versionSpec: ${{ env.GitToolVersion }}
includePrerelease: true

# Run GitVersion
- name: Execute GitVersion
id: gitversion # GitHub Actions ID for future reference
uses: gittools/actions/execute@v0
with:
useConfigFile: true
configFilePath: "GitVersion.yml"

# Set the build number based on GitVersion
- name: Set Build Number
run: |
echo "Build number: ${{ steps.gitversion.outputs.semver }}"
echo "GITHUB_RUN_NUMBER=${{ steps.gitversion.outputs.semver }}" >> $GITHUB_ENV
# Set GitVersion variables for later use
- name: Set GitVersion variables
run: |
echo "SemVer=${{ steps.gitversion.outputs.semver }}" >> $GITHUB_ENV
echo "MajorMinorPatch=${{ steps.gitversion.outputs.majorminorpatch }}" >> $GITHUB_ENV
# Tag the repository (only for main or release branches, not pull requests)
- name: Tag repo
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/'))
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.gitversion.outputs.semver }}
git push origin ${{ steps.gitversion.outputs.semver }}
122 changes: 122 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
mode: ManualDeployment
commit-message-incrementing: Enabled
strategies:
- Fallback
- MergeMessage
- TaggedCommit

branches:
main:
mode: ManualDeployment
label: 'rev'
increment: Minor
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: true
track-merge-target: true
track-merge-message: true
regex: ^main$|^master$
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 60000

develop:
mode: ManualDeployment
label: 'rev'
increment: Minor
prevent-increment:
when-current-commit-tagged: false
track-merge-target: true
track-merge-message: true
regex: ^develop$
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
pre-release-weight: 60000

release:
mode: ManualDeployment
label: 'rev'
increment: Patch
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: true
regex: ^releas(e|es)?[/-]
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000

feature:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
prevent-increment:
when-current-commit-tagged: false
track-merge-target: true
track-merge-message: true
regex: ^features?[/-](?<BranchName>.+)
source-branches:
- feature
- hotfix
- develop
- main
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
pre-release-weight: 30000

pull-request:
mode: ContinuousDelivery
label: 'PR'
increment: Inherit
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
label-number-pattern: '[/-](?<number>\d+)'
track-merge-target: false
track-merge-message: true
regex: ^pull?
source-branches:
- develop
- main
- release
- feature
- hotfix
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
pre-release-weight: 30000

hotfix:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Patch
prevent-increment:
when-current-commit-tagged: false
track-merge-target: true
regex: ^hotfix(es)?[/-]
source-branches:
- main
- develop
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000

ignore:
sha: []

0 comments on commit 5beb369

Please sign in to comment.