diff --git a/.github/workflows/bump-controls.yml b/.github/workflows/bump-controls.yml new file mode 100644 index 000000000000..85d4578e7784 --- /dev/null +++ b/.github/workflows/bump-controls.yml @@ -0,0 +1,85 @@ +# Copyright (c) Files Community +# Licensed under the MIT License. + +# Abstract: +# Bumps the version of the Files UI Controls library +# +# Workflow: +# 1. Find the version of the Files UI Controls library +# 2. Bump the version of the Files UI Controls library +# 3. Commit the changes to a new branch in the repo +# 4. Push the changes to the repo +# 5. Create a pull request and request a review + +name: Bump Files.App.Controls + +on: + workflow_dispatch: + +jobs: + bump: + runs-on: windows-latest + environment: Pull Requests + strategy: + fail-fast: false + env: + WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ + VERSION_PROPS_PATH: '${{ github.workspace }}\src\Files.App.Controls\CurrentVersion.props' + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Generate GitHub Apps token + if: github.repository_owner == 'files-community' + id: generate + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.BOT_APP_ID }} + private-key: ${{ secrets.BOT_PRIVATE_KEY }} + + - name: Bump Version + id: bump_version + shell: pwsh + run: | + $xml = [xml](Get-Content $env:PROPS_PATH) + $version = [int]$xml.Project.PropertyGroup.MicroVersion + $newVersion = $version + 1 + $xml.Project.PropertyGroup.MicroVersion = $newVersion + $xml.Save($env:PROPS_PATH) + Write-Output "Bumped version to $newVersion" + echo "::set-output name=new_version::$newVersion" + + - name: Get version for PR message + id: get_version + shell: pwsh + run: | + $xml = [xml](Get-Content $env:PROPS_PATH) + $microVersion = [int]$xml.Project.PropertyGroup.MicroVersion + $minorVersion = [int]$xml.Project.PropertyGroup.MinorVersion + $majorVersion = [int]$xml.Project.PropertyGroup.MajorVersion + $fullVersion = "$majorVersion.$minorVersion.$microVersion" + Write-Output "Found publish version, $fullVersion" + echo "::set-output name=full_version::$fullVersion" + + - name: Add and commit changes + uses: EndBug/add-and-commit@v9 + with: + add: '${{ env.VERSION_PROPS_PATH }}' + + author_name: files-community-bot[bot] + author_email: 152337890+files-community-bot[bot]@users.noreply.github.com + default_author: github_actor + + message: 'Bump Files UI controls version to ${{ steps.get_version.outputs.full_version }}' + new_branch: 'files/ui-controls/${{ steps.get_version.outputs.full_version }}' + + pathspec_error_handling: ignore + push: true + + - name: Create Pull Request + shell: pwsh + env: + GH_TOKEN: ${{ steps.generate.outputs.token }} + run: | + gh pr create --title "Controls: Bumped Controls version to ${{ steps.get_version.outputs.full_version }}" --body "This is an automated PR that bumps the version of the Files UI controls project." --base main --head bot/ui-controls/${{ steps.get_version.outputs.full_version }} diff --git a/.github/workflows/cd-controls.yml b/.github/workflows/cd-controls.yml new file mode 100644 index 000000000000..0324656e5c7f --- /dev/null +++ b/.github/workflows/cd-controls.yml @@ -0,0 +1,70 @@ +# Copyright (c) Files Community +# Licensed under the MIT License. + +# Abstract: +# Deploys the Files UI Controls library to NuGet +# +# Workflow: +# 1. Restore and build Files UI Controls +# 2. Generate a NuGet package and symbols +# 3. Publish the artifacts to NuGet + +name: Files CD (UI Controls) + +on: + push: + branches: + - main + paths: + - src/Files.App.Controls/CurrentVersion.props + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + environment: Deployments + strategy: + fail-fast: false + env: + SOLUTION_NAME: 'Files.slnx' + CONFIGURATION: 'Release' # It's not necessary to use a matrix as the package method will always be Release + PLATFORM: 'x64' + WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ + PROJECT_DIR: '${{ github.workspace }}\src\Files.App.Controls' + PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App.Controls\Files.App.Controls.csproj' + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + - name: Use Windows SDK Preview + shell: cmd + run: | + for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt + + - name: Restore NuGet + shell: pwsh + run: | + msbuild $env:PACKAGE_PROJECT_PATH ` + -t:Restore ` + -p:Platform=$env:PLATFORM ` + -p:Configuration=$env:CONFIGURATION + + - name: Build Files UI Controls + run: | + msbuild "$env:PACKAGE_PROJECT_PATH" ` + -t:Build ` + -p:Platform=$env:PLATFORM ` + -p:Configuration=$env:CONFIGURATION ` + -p:PackageOutputPath="$env:WORKING_DIR\output" + + - name: Publish package to NuGet + run: dotnet nuget push ./output/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/src/Files.App.Controls/CurrentVersion.props b/src/Files.App.Controls/CurrentVersion.props new file mode 100644 index 000000000000..82872135757b --- /dev/null +++ b/src/Files.App.Controls/CurrentVersion.props @@ -0,0 +1,15 @@ +<!-- Copyright (c) Files Community. Licensed under the MIT License. --> +<!-- READ ME BEFORE MODIFYING THIS FILE: + This file is used to track the version of the Files UI Controls package online. + The version is automatically bumped by the 'Bump Files UI Controls' action online. + You can bump the version here in a PR and when it is merged the controls project + will be automatically published to NuGet online. --> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <MajorVersion>1</MajorVersion> + <MinorVersion>0</MinorVersion> + <!-- This version is bumped automatically by CI. --> + <MicroVersion>0</MicroVersion> + <Version>$(MajorVersion).$(MinorVersion).$(MicroVersion)</Version> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index e2f44e087d4d..faf36135b50c 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -1,6 +1,6 @@ -<!-- Copyright (c) Files Community. Licensed under the MIT License. --> +<!-- Copyright (c) Files Community. Licensed under the MIT License. --> <Project Sdk="Microsoft.NET.Sdk"> - + <Import Project="CurrentVersion.props" /> <PropertyGroup> <TargetFramework>$(WindowsTargetFramework)</TargetFramework> <TargetPlatformMinVersion>$(MinimalWindowsVersion)</TargetPlatformMinVersion> @@ -12,6 +12,32 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> + <PropertyGroup> + <GeneratePackageOnBuild>True</GeneratePackageOnBuild> + <Title>Files UI Controls</Title> + <Authors>files-community</Authors> + <Company>Files Community</Company> + <Copyright>Copyright (c) Files Community</Copyright> + <PackageReadmeFile>README.md</PackageReadmeFile> + <RepositoryUrl>https://github.com/files-community/Files</RepositoryUrl> + <RepositoryType>git</RepositoryType> + <PackageTags>files, files-community, winui, winappsdk</PackageTags> + <Description>Elevate your WinUI applications with our collection of custom-built controls, crafted specifically to address our needs in Files. These controls are provided "as is", with no guaranteed support, but we hope they prove useful to the developer community.</Description> + <PackageLicenseExpression>MIT</PackageLicenseExpression> + <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance> + <IncludeSymbols>True</IncludeSymbols> + <SymbolPackageFormat>snupkg</SymbolPackageFormat> + <PackageProjectUrl>https://files.community</PackageProjectUrl> + <PackageIcon>StoreLogo.scale-400.png</PackageIcon> + </PropertyGroup> + + <ItemGroup> + <None Include="..\Files.App (Package)\Assets\AppTiles\Release\StoreLogo.scale-400.png"> + <Pack>True</Pack> + <PackagePath>\</PackagePath> + </None> + </ItemGroup> + <ItemGroup> <PackageReference Include="CommunityToolkit.WinUI.Extensions" /> <PackageReference Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" /> @@ -25,4 +51,11 @@ <ProjectReference Include="..\Files.Core.SourceGenerator\Files.Core.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> </ItemGroup> + <ItemGroup> + <None Include="README.md"> + <Pack>True</Pack> + <PackagePath>\</PackagePath> + </None> + </ItemGroup> + </Project> diff --git a/src/Files.App.Controls/README.md b/src/Files.App.Controls/README.md new file mode 100644 index 000000000000..e5a8ed636dcc --- /dev/null +++ b/src/Files.App.Controls/README.md @@ -0,0 +1,12 @@ +> These controls are provided "as is", with no guaranteed support, but we hope they prove useful to the developer community. +# 📁 Files UI Controls + +##### Elevate your WinUI applications with our collection of custom-built controls, crafted specifically to address our needs in Files. + +--- + +This package contains various controls for the [Files app](https://files.community), including `ThemedIcon`, `Toolbar` and various storage controls. +It is available [on NuGet](https://www.nuget.org/packages/Files.App.Controls), however is unlisted and can only be installed by manually typing the package name and version number into the MSBuild project file. + +Please do not open issues on the Files repository about this package, as it is not officially supported by the Files team and is provided as is. +If you have questions about the design or implementation of these controls, please ask [on Discord](https://discord.gg/files).