diff --git a/.github/workflows/cd-dry-run.yml b/.github/workflows/cd-dry-run.yml index 07001880..aa67af0a 100644 --- a/.github/workflows/cd-dry-run.yml +++ b/.github/workflows/cd-dry-run.yml @@ -3,17 +3,16 @@ name: Daybreak Dry-Run CD Pipeline on: - push: + pull_request: branches: - master paths: - - "Daybreak/**" + - "Daybreak.Core/**" - "Daybreak.Installer/**" - "Daybreak.API/**" - - "Daybreak.7ZipExtractor/**" - - "Daybreak.Installer/**" - "Daybreak.Shared/**" - workflow_dispatch: + - "Daybreak.Windows/**" + - "Daybreak.Linux/**" jobs: cd: diff --git a/.github/workflows/cd-template.yml b/.github/workflows/cd-template.yml index efd927b9..09e787e1 100644 --- a/.github/workflows/cd-template.yml +++ b/.github/workflows/cd-template.yml @@ -18,6 +18,9 @@ jobs: build-x86: runs-on: windows-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + env: Configuration: Release Actions_Allow_Unsecure_Commands: true @@ -29,6 +32,13 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Get version + id: get_version + shell: pwsh + run: | + $version = (Select-String -Path Directory.Build.props -Pattern '(.*)').Matches.Groups[1].Value + echo "version=$version" >> $env:GITHUB_OUTPUT + - name: Install .NET uses: actions/setup-dotnet@v5 with: @@ -149,24 +159,14 @@ jobs: # Stage 3 — Package (always) # ─────────────────────────────────────────────────────── package: - needs: [build-windows, build-linux] + needs: [build-x86, build-windows, build-linux] runs-on: ubuntu-latest env: Actions_Allow_Unsecure_Commands: true + Version: ${{ needs.build-x86.outputs.version }} steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - submodules: recursive - - - name: Set version variable - run: | - version=$(grep '' Directory.Build.props | sed 's/.*\(.*\)<\/Version>.*/\1/') - echo "Version=$version" >> $GITHUB_ENV - # ── Windows package ── - name: Download Windows build uses: actions/download-artifact@v7 @@ -218,12 +218,13 @@ jobs: # Stage 4 — Release (optional) # ─────────────────────────────────────────────────────── release: - needs: package + needs: [build-x86, package] runs-on: ubuntu-latest if: ${{ inputs.publishRelease }} env: Actions_Allow_Unsecure_Commands: true + Version: ${{ needs.build-x86.outputs.version }} steps: - name: Checkout @@ -243,17 +244,12 @@ jobs: uses: WyriHaximus/github-action-get-previous-tag@v2 - name: Generate changelog - id: gen_changelog + id: changelog run: | changeLog=$(git log --no-merges --pretty="%h - %s (%an)
" ${{ steps.getLatestTag.outputs.tag }}..HEAD) - echo "Changelog<> $GITHUB_ENV - echo "$changeLog" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - - name: Set version variable - run: | - version=$(grep '' Directory.Build.props | sed 's/.*\(.*\)<\/Version>.*/\1/') - echo "Version=$version" >> $GITHUB_ENV + echo "content<> $GITHUB_OUTPUT + echo "$changeLog" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT # ── Release ── - name: Create release draft @@ -263,13 +259,11 @@ jobs: tag_name: v${{ env.Version }} release_name: Daybreak v${{ env.Version }} assets: release-assets/daybreakv${{ env.Version }}.zip;release-assets/daybreakv${{ env.Version }}-linux.zip - github_token: ${{ env.GITHUB_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} replace_assets: true body_mrkdwn: | - ${{ env.Changelog }} + ${{ steps.changelog.outputs.content }} isDraft: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish release run: gh release edit v${{ env.Version }} --draft=false diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 4fd97dcc..97d0bad3 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -9,12 +9,12 @@ on: branches: - master paths: - - "Daybreak/**" + - "Daybreak.Core/**" - "Daybreak.Installer/**" - "Daybreak.API/**" - - "Daybreak.7ZipExtractor/**" - - "Daybreak.Installer/**" - "Daybreak.Shared/**" + - "Daybreak.Windows/**" + - "Daybreak.Linux/**" workflow_dispatch: jobs: diff --git a/.github/workflows/create-build-release-branch.yml b/.github/workflows/create-build-release-branch.yml new file mode 100644 index 00000000..69616333 --- /dev/null +++ b/.github/workflows/create-build-release-branch.yml @@ -0,0 +1,12 @@ +# Manually trigger to create a new release branch with bumped build version +name: Create Build Release Branch + +on: + workflow_dispatch: + +jobs: + create-release: + uses: ./.github/workflows/create-release-branch-template.yml + with: + versionBump: bump-build + secrets: inherit diff --git a/.github/workflows/create-major-release-branch.yml b/.github/workflows/create-major-release-branch.yml new file mode 100644 index 00000000..4d6a3985 --- /dev/null +++ b/.github/workflows/create-major-release-branch.yml @@ -0,0 +1,12 @@ +# Manually trigger to create a new release branch with bumped major version +name: Create Major Release Branch + +on: + workflow_dispatch: + +jobs: + create-release: + uses: ./.github/workflows/create-release-branch-template.yml + with: + versionBump: bump-major + secrets: inherit diff --git a/.github/workflows/create-minor-release-branch.yml b/.github/workflows/create-minor-release-branch.yml new file mode 100644 index 00000000..7e7ec02e --- /dev/null +++ b/.github/workflows/create-minor-release-branch.yml @@ -0,0 +1,12 @@ +# Manually trigger to create a new release branch with bumped minor version +name: Create Minor Release Branch + +on: + workflow_dispatch: + +jobs: + create-release: + uses: ./.github/workflows/create-release-branch-template.yml + with: + versionBump: bump-minor + secrets: inherit diff --git a/.github/workflows/create-release-branch-template.yml b/.github/workflows/create-release-branch-template.yml new file mode 100644 index 00000000..b61fd5b4 --- /dev/null +++ b/.github/workflows/create-release-branch-template.yml @@ -0,0 +1,66 @@ +# Reusable template for creating release branches with version bumps +name: Create Release Branch Template + +on: + workflow_call: + inputs: + versionBump: + description: "Version bump command: bump-major, bump-minor, bump-build, bump-revision" + required: true + type: string + +jobs: + create-release-branch: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Bump version in Directory.Build.props + id: bump + uses: vers-one/dotnet-project-version-updater@v1.7 + with: + file: "Directory.Build.props" + version: ${{ inputs.versionBump }} + + - name: Check if release branch already exists + id: check_branch + run: | + branch_name="release/${{ steps.bump.outputs.newVersion }}" + if git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then + echo "Branch $branch_name already exists" + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "Branch $branch_name does not exist" + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Create release branch + if: steps.check_branch.outputs.exists == 'false' + run: | + new_version="${{ steps.bump.outputs.newVersion }}" + branch_name="release/$new_version" + + # Create new branch from master + git checkout -b "$branch_name" + + # Commit the version change (already updated by the action) + git add Directory.Build.props + git commit -m "Bump version to $new_version" + + # Push the new branch + git push origin "$branch_name" + + echo "✅ Created release branch: $branch_name with version $new_version" diff --git a/.github/workflows/create-revision-release-branch.yml b/.github/workflows/create-revision-release-branch.yml new file mode 100644 index 00000000..749e5dc9 --- /dev/null +++ b/.github/workflows/create-revision-release-branch.yml @@ -0,0 +1,20 @@ +# Automatically creates a new release branch with bumped revision +# after a successful CD pipeline run on master +name: Create Revision Release Branch + +on: + workflow_run: + workflows: ["Daybreak CD Pipeline"] + types: + - completed + branches: + - master + +jobs: + create-release: + # Only run if the CD pipeline succeeded + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: ./.github/workflows/create-release-branch-template.yml + with: + versionBump: bump-revision + secrets: inherit diff --git a/.github/workflows/version_check.yaml b/.github/workflows/version_check.yaml index a76fc65b..af76ecd9 100644 --- a/.github/workflows/version_check.yaml +++ b/.github/workflows/version_check.yaml @@ -5,13 +5,12 @@ on: branches: - master paths: - - "Daybreak/**" + - "Daybreak.Core/**" - "Daybreak.Installer/**" - - "Daybreak.Linux/**" - - "Daybreak.Windows/**" - "Daybreak.API/**" - "Daybreak.Shared/**" - - "Daybreak.Injector/**" + - "Daybreak.Windows/**" + - "Daybreak.Linux/**" jobs: check_version: @@ -44,15 +43,13 @@ jobs: - name: Build Daybreak project run: dotnet build Daybreak.Linux -c $Configuration --property:SolutionDir=$GITHUB_WORKSPACE - - name: Set version variable + - name: Get version + id: get_version run: | version=$(grep '' Directory.Build.props | sed 's/.*\(.*\)<\/Version>.*/\1/') - echo "Version=$version" >> $GITHUB_ENV + echo "version=$version" >> $GITHUB_OUTPUT - name: Check version difference - run: pwsh ./Scripts/CompareVersions.ps1 -currentVersion ${{ env.Version }} -lastVersion ${{ env.LatestReleaseTag }} - env: - LatestReleaseTag: ${{ steps.getLatestTag.outputs.tag }} - shell: - pwsh + run: pwsh ./Scripts/CompareVersions.ps1 -currentVersion ${{ steps.get_version.outputs.version }} -lastVersion ${{ steps.getLatestTag.outputs.tag }} + shell: pwsh