-
Notifications
You must be signed in to change notification settings - Fork 1
Add automated winget package submission #142
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
ade312a
89f88ae
4de031c
01fcd49
2ff7692
11ec565
88f9bd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,15 @@ jobs: | |
| cd bin && tar -czf $APP_NAME.$TARGET.tar.gz ${APP_NAME}${EXT} | ||
| ls -la | ||
|
|
||
| - name: Upload Release Asset | ||
| # Create ZIP file for Windows (required for winget) | ||
| - name: Create Windows ZIP | ||
| if: github.event_name == 'release' && matrix.target.name == 'x86_64-pc-windows-msvc' | ||
| run: | | ||
| cd bin | ||
| zip $APP_NAME.${{ matrix.target.name }}.zip ${APP_NAME}.exe | ||
| ls -la | ||
|
|
||
| - name: Upload Release Asset (tar.gz) | ||
| uses: actions/upload-release-asset@v1 | ||
| if: github.event_name == 'release' | ||
| env: | ||
|
|
@@ -77,6 +85,17 @@ jobs: | |
| asset_name: ${{ env.APP_NAME }}.${{ matrix.target.name }}.tar.gz | ||
| asset_content_type: application/tar+gzip | ||
|
|
||
| - name: Upload Release Asset (zip for Windows) | ||
| uses: actions/upload-release-asset@v1 | ||
| if: github.event_name == 'release' && matrix.target.name == 'x86_64-pc-windows-msvc' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: ./bin/${{ env.APP_NAME }}.${{ matrix.target.name }}.zip | ||
| asset_name: ${{ env.APP_NAME }}.${{ matrix.target.name }}.zip | ||
| asset_content_type: application/zip | ||
|
|
||
| - name: Print Output | ||
| if: github.event_name == 'release' | ||
| env: | ||
|
|
@@ -277,6 +296,214 @@ jobs: | |
| --head "${branch_name}" \ | ||
| --base main | ||
|
|
||
| winget: | ||
| if: ${{ github.event_name == 'release' && github.event.release.prerelease == false }} | ||
| runs-on: windows-latest | ||
| needs: | ||
| - version | ||
| - assets | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| env: | ||
| GH_TOKEN: ${{ secrets.SEMVER_PUBLISH_TOKEN }} | ||
| GITHUB_TOKEN: ${{ secrets.SEMVER_PUBLISH_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config --global user.name 'github-actions[bot]' | ||
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
| gh auth setup-git | ||
|
|
||
| - name: Download Release Asset and Generate Winget Manifests | ||
| env: | ||
| VERSION: ${{ needs.version.outputs.version }} | ||
| shell: bash | ||
| run: | | ||
| mkdir -p assets manifests | ||
|
|
||
| # Download the Windows ZIP asset using GitHub CLI | ||
| asset_name="semver.x86_64-pc-windows-msvc.zip" | ||
| echo "Downloading ${asset_name} using GitHub CLI" | ||
| gh release download "${VERSION}" --pattern "${asset_name}" --dir assets --repo Optum/semver-cli | ||
|
|
||
| # Calculate SHA256 (PowerShell command via bash, convert to lowercase) | ||
| sha=$(powershell -Command "(Get-FileHash -Algorithm SHA256 assets/${asset_name}).Hash.ToLower()") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Can you do this without powershell? I don't think its necessary you should be able to do it right from bash directly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Removed PowerShell dependency in commit 2ff7692. Now using bash's |
||
| echo "SHA256: $sha" | ||
|
|
||
| url="https://github.com/Optum/semver-cli/releases/download/${VERSION}/${asset_name}" | ||
| echo "URL: $url" | ||
|
|
||
| # Get release date from GitHub event (fallback to current date if not available) | ||
| release_date="${{ github.event.release.published_at }}" | ||
| if [ -z "$release_date" ]; then | ||
| release_date=$(date -u +%Y-%m-%d) | ||
| else | ||
| # Extract just the date portion (YYYY-MM-DD) from the ISO timestamp | ||
| release_date=$(echo "$release_date" | cut -d'T' -f1) | ||
| fi | ||
| echo "Release Date: $release_date" | ||
|
|
||
| # Create manifest directory structure | ||
| # Winget uses: manifests/<first-letter-lowercase>/<Publisher>/<PackageName>/<Version>/ | ||
| manifest_dir="manifests/o/Optum/semver/${VERSION}" | ||
| mkdir -p "$manifest_dir" | ||
|
|
||
| # Generate the installer manifest | ||
| cat > "${manifest_dir}/Optum.semver.installer.yaml" << EOF | ||
| # yaml-language-server: \$schema=https://aka.ms/winget-manifest.installer.1.6.0.schema.json | ||
|
|
||
| PackageIdentifier: Optum.semver | ||
| PackageVersion: ${VERSION} | ||
| InstallerType: zip | ||
| UpgradeBehavior: install | ||
| Commands: | ||
| - semver | ||
| ReleaseDate: ${release_date} | ||
| Installers: | ||
| - Architecture: x64 | ||
| NestedInstallerType: portable | ||
| NestedInstallerFiles: | ||
| - RelativeFilePath: semver.exe | ||
| PortableCommandAlias: semver | ||
| InstallerUrl: ${url} | ||
| InstallerSha256: ${sha} | ||
| ManifestType: installer | ||
| ManifestVersion: 1.6.0 | ||
| EOF | ||
|
|
||
| # Generate the locale manifest | ||
| cat > "${manifest_dir}/Optum.semver.locale.en-US.yaml" << EOF | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move these files to be files in the repo in a manifests directory.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Moved manifest files to the repo in commit 2ff7692. Created |
||
| # yaml-language-server: \$schema=https://aka.ms/winget-manifest.defaultLocale.1.6.0.schema.json | ||
|
|
||
| PackageIdentifier: Optum.semver | ||
| PackageVersion: ${VERSION} | ||
| PackageLocale: en-US | ||
| Publisher: Optum | ||
| PublisherUrl: https://github.com/Optum | ||
| PublisherSupportUrl: https://github.com/Optum/semver-cli/issues | ||
| Author: Optum | ||
| PackageName: semver | ||
| PackageUrl: https://github.com/Optum/semver-cli | ||
| License: Apache-2.0 | ||
| LicenseUrl: https://github.com/Optum/semver-cli/blob/HEAD/LICENSE | ||
| Copyright: Copyright (c) Optum | ||
| ShortDescription: A technology agnostic cli for common semantic versioning operations | ||
| Description: A technology agnostic cli for common semantic versioning operations. Built with Deno. | ||
| Moniker: semver | ||
| Tags: | ||
| - cli | ||
| - semver | ||
| - semantic-version | ||
| - versioning | ||
| - deno | ||
| ReleaseNotesUrl: https://github.com/Optum/semver-cli/releases/tag/${VERSION} | ||
| ManifestType: defaultLocale | ||
| ManifestVersion: 1.6.0 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these versions need to be added to the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Added version patterns to |
||
| EOF | ||
|
|
||
| # Generate the version manifest | ||
| cat > "${manifest_dir}/Optum.semver.yaml" << EOF | ||
| # yaml-language-server: \$schema=https://aka.ms/winget-manifest.version.1.6.0.schema.json | ||
|
|
||
| PackageIdentifier: Optum.semver | ||
| PackageVersion: ${VERSION} | ||
| DefaultLocale: en-US | ||
| ManifestType: version | ||
| ManifestVersion: 1.6.0 | ||
| EOF | ||
|
|
||
| echo "Generated manifests:" | ||
| ls -la "${manifest_dir}" | ||
| cat "${manifest_dir}/Optum.semver.installer.yaml" | ||
| cat "${manifest_dir}/Optum.semver.locale.en-US.yaml" | ||
| cat "${manifest_dir}/Optum.semver.yaml" | ||
|
|
||
| - name: Validate Winget Manifests | ||
| env: | ||
| VERSION: ${{ needs.version.outputs.version }} | ||
| shell: bash | ||
| run: | | ||
| manifest_dir="manifests/o/Optum/semver/${VERSION}" | ||
|
|
||
| # Install winget (if not already available on Windows runner) | ||
| # Windows runners typically have winget pre-installed | ||
|
|
||
| # Validate manifests using winget | ||
| echo "Validating manifests with winget..." | ||
| if ! winget validate "${manifest_dir}"; then | ||
| echo "::error::Winget manifest validation failed" | ||
| exit 1 | ||
| fi | ||
| echo "Validation successful!" | ||
|
|
||
| # Output to GitHub Summary | ||
| cat >> $GITHUB_STEP_SUMMARY << EOF | ||
| ## Winget Manifests Generated | ||
|
|
||
| Successfully generated Winget manifests for version **${VERSION}**. | ||
|
|
||
| ### Manifest Details | ||
| - **Package Identifier**: Optum.semver | ||
| - **Version**: ${VERSION} | ||
| - **Architecture**: x64 | ||
| - **Installer Type**: zip (portable) | ||
|
|
||
| ### Files Generated | ||
| - Optum.semver.installer.yaml | ||
| - Optum.semver.locale.en-US.yaml | ||
| - Optum.semver.yaml | ||
| EOF | ||
|
|
||
| - name: Create PR to Winget Repository | ||
| env: | ||
| VERSION: ${{ needs.version.outputs.version }} | ||
| shell: bash | ||
| run: | | ||
| # Clone the winget-pkgs repository | ||
| gh repo clone microsoft/winget-pkgs winget-pkgs-repo | ||
| cd winget-pkgs-repo | ||
|
|
||
| # Create a new branch | ||
| branch_name="Optum.semver-${VERSION}" | ||
| git checkout -b "${branch_name}" | ||
|
|
||
| # Copy the generated manifests | ||
| manifest_dir="../manifests/o/Optum/semver/${VERSION}" | ||
| target_dir="manifests/o/Optum/semver/${VERSION}" | ||
| mkdir -p "${target_dir}" | ||
| cp "${manifest_dir}"/* "${target_dir}/" | ||
|
|
||
| # Commit and push the changes | ||
| git add "manifests/o/Optum/semver/${VERSION}" | ||
| git commit -m "New version: Optum.semver version ${VERSION}" | ||
| git push origin "${branch_name}" | ||
|
|
||
| # Create the PR | ||
| gh pr create \ | ||
| --repo microsoft/winget-pkgs \ | ||
| --title "New version: Optum.semver version ${VERSION}" \ | ||
| --body "This PR adds Optum.semver version ${VERSION} to the Windows Package Manager repository. | ||
|
|
||
| **Package Information:** | ||
| - **Package Identifier**: Optum.semver | ||
| - **Version**: ${VERSION} | ||
| - **Publisher**: Optum | ||
| - **License**: Apache-2.0 | ||
|
|
||
| **Changes:** | ||
| - Added new package version ${VERSION} | ||
| - Installer type: zip (portable) | ||
| - Architecture: x64 | ||
|
|
||
| This PR was automatically generated by the semver-cli release workflow. | ||
|
|
||
| **Release Notes**: https://github.com/Optum/semver-cli/releases/tag/${VERSION}" \ | ||
| --head "${branch_name}" \ | ||
| --base master | ||
|
|
||
| tags: | ||
| if: ${{ github.event.release.prerelease == false }} | ||
| runs-on: ubuntu-latest | ||
|
|
@@ -285,6 +512,7 @@ jobs: | |
| - assets | ||
| - docker | ||
| - homebrew | ||
| - winget | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,14 @@ brew install optum/tap/semver | |
|
|
||
| via [optum](https://github.com/Optum/homebrew-tap) | ||
|
|
||
| ## Winget (Windows Package Manager) | ||
|
|
||
| ```sh | ||
| winget install Optum.semver | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make the packages name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Changed package name from |
||
| ``` | ||
|
|
||
| via [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs) | ||
|
|
||
| ## From Source | ||
|
|
||
| Installation from source will require | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this here, we're already uploading the exe file as an asset, if you need it zipped for winget then do it in the package step after you download the asset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Removed ZIP creation from assets job in commit 2ff7692. Now the
winget-package.shscript downloads the .exe from the release asset (tar.gz), extracts it, and creates the ZIP file. The ZIP is then uploaded as a separate release asset by the winget job.