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

Controls: Added metadata to the Controls project to enable publishing to NuGet #16611

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4550b6a
Add package metadata
Lamparter Dec 16, 2024
5656e61
Add package README
Lamparter Dec 16, 2024
ab85e84
New package description
Lamparter Dec 16, 2024
dc679ab
Change package description in README
Lamparter Dec 16, 2024
35774d2
Change authors to just "files-community"
Lamparter Dec 17, 2024
8755b58
Initial addition of CI
Lamparter Dec 17, 2024
8333345
Add PR run for CI to test
Lamparter Dec 17, 2024
07c4217
Update cd-controls.yml
Lamparter Dec 17, 2024
b60e8bf
Update cd-controls.yml
Lamparter Dec 17, 2024
e1b9694
Fix version script
Lamparter Dec 17, 2024
30be097
Fix appxpackage reference
Lamparter Dec 17, 2024
9c5fdef
Fix reference to UI controls project
Lamparter Dec 17, 2024
0b222a6
Update cd-controls.yml
Lamparter Dec 17, 2024
16c106c
Update cd-controls.yml
Lamparter Dec 21, 2024
3bd08fc
Move comma
Lamparter Dec 24, 2024
47bbe68
Move comma in `README.md`
Lamparter Dec 24, 2024
6135043
Add more tags
Lamparter Dec 24, 2024
e38ab75
Replace secret direct link with placeholder
Lamparter Feb 2, 2025
d17dc44
Update license header
Lamparter Feb 2, 2025
ca1b6e2
Rename potential deployment space to "NuGet"
Lamparter Feb 2, 2025
1a9d698
Remove accidental space
Lamparter Feb 2, 2025
67e41e0
Replace tab formatting with spaces
Lamparter Feb 2, 2025
aa407da
Include README via `Include=` rather than `Update=`
Lamparter Feb 3, 2025
7e3f286
Add versioning file
Lamparter Feb 8, 2025
5045871
Remove 'extract version' step
Lamparter Feb 9, 2025
0f616d2
Reference version in project
Lamparter Feb 9, 2025
61f221c
New workflow
Lamparter Feb 9, 2025
0f492a4
Add PR creation step
Lamparter Feb 9, 2025
6f2f9f2
Remove ``
Lamparter Feb 9, 2025
6c3623f
Remove `--body`
Lamparter Feb 9, 2025
307a292
`""` > `''`
Lamparter Feb 9, 2025
cb14db7
`GH_TOKEN`
Lamparter Feb 9, 2025
0b7ac74
Example
Lamparter Feb 9, 2025
84bbad3
Sample bot
Lamparter Feb 9, 2025
3e5c8df
Fix custom actor
Lamparter Feb 9, 2025
257757d
Improve message
Lamparter Feb 9, 2025
44d6400
Change PR prefix
Lamparter Feb 9, 2025
a19aaa0
Remove CLI newline switch
Lamparter Feb 9, 2025
1c2e910
Update copyright year
Lamparter Mar 17, 2025
518b1ad
Reword warning
Lamparter Mar 17, 2025
007069d
Update to SLNX
Lamparter Mar 18, 2025
f96a846
Merge steps
Lamparter Mar 18, 2025
90eb94b
Update .github/workflows/bump-controls.yml
Lamparter Mar 18, 2025
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
113 changes: 113 additions & 0 deletions .github/workflows/bump-controls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# 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 UI Controls

on:
workflow_dispatch:
pull_request:
branches: [ "main" ]

jobs:
bump:
runs-on: windows-latest
environment: Pull Requests
strategy:
fail-fast: false
env:
WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\
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 == 'Lamparter'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be switched to files-community.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware, this is one of the things that needs to be done right before merge. Changing this would mean I can't test it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If everything else is ready, we should make this change and merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure
Fingers crossed it works

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:
# The arguments for the `git add` command
# Default: '.'
add: '${{ env.PROPS_PATH }}'

# The name of the user that will be displayed as the author of the commit.
# Default: depends on the default_author input
author_name: files-community-bot[bot]

# The email of the user that will be displayed as the author of the commit.
# Default: depends on the default_author input
author_email: 152337890+files-community-bot[bot]@users.noreply.github.com

# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <UserName@users.noreply.github.com>
# - user_info -> Your Display Name <your-actual@email.com>
# - github_actions -> github-actions <email associated with the github logo>
# Default: github_actor
default_author: github_actor

# The message for the commit.
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: 'Bump Files UI controls version to ${{ steps.get_version.outputs.full_version }}'

# If this input is set, the action will push the commit to a new branch with this name.
# Default: ''
new_branch: 'files/ui-controls/${{ steps.get_version.outputs.full_version }}'

# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
# - ignore -> errors will be logged but the step won't fail
# - exitImmediately -> the action will stop right away, and the step will fail
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
# Default: ignore
pathspec_error_handling: ignore

# Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info)
# Default: true
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 files/ui-controls/${{ steps.get_version.outputs.full_version }}
70 changes: 70 additions & 0 deletions .github/workflows/cd-controls.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow should automatically run after bumping the version number. However, it should not run every time we merge a PR into main, otherwise it will create extra noise which we wish to avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't, it will only run on every push to main that has a change to CurrentVersion.props.
Changing this before merge will make it impossible to test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we test by bumping the version number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant we can test by modifying CurrentVersion.props

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's nicer to test here by just any commit.
Regardless it won't work because there isn't a token yet.
It doesn't matter at the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The token is already configured, if everything else is ready, we should make this change and merge.

workflow_dispatch:
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: windows-latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: windows-latest
runs-on: windows-latest
environment: Deployments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly recommend against using the same environment for different things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app CD workflow and UI controls CD workflow should be in different environments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grouped them together as they are both deployments. We can separate them if there is a good reason to, but I may have to generate new tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They will need to be separate as the CD for the app requires approval but the CD for the Controls project won't (as it will add extra hassle)

Copy link
Member

@yaira2 yaira2 Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The controls project will require approval as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it makes sense to put them in separate deployment environments as they deploy to separate deployment environments

#environment: NuGet
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 8
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 (SECRET GOES HERE) --source https://api.nuget.org/v3/index.json
15 changes: 15 additions & 0 deletions src/Files.App.Controls/CurrentVersion.props
Original file line number Diff line number Diff line change
@@ -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>
37 changes: 35 additions & 2 deletions src/Files.App.Controls/Files.App.Controls.csproj
Original file line number Diff line number Diff line change
@@ -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>
12 changes: 12 additions & 0 deletions src/Files.App.Controls/README.md
Original file line number Diff line number Diff line change
@@ -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).
Loading
Oops, something went wrong.