Skip to content

Commit

Permalink
chore(release): winget-releaser v2 (#93)
Browse files Browse the repository at this point in the history
* Move .github/CODE_OF_CONDUCT.md to CODE_OF_CONDUCT.md

* Update tsconfig.json

* Update action

* Update CONTRIBUTING.md

* Update README.md

* Update main.ts

Signed-off-by: Vedant <[email protected]>

* Update dist/index.js

---------

Signed-off-by: Vedant <[email protected]>
  • Loading branch information
vedantmgoyal9 authored Feb 12, 2023
1 parent baef551 commit 9b1e902
Show file tree
Hide file tree
Showing 12 changed files with 2,146 additions and 8,543 deletions.
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md → CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
https://github.com/vedantmgoyal2009/winget-releaser/issues.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Ensure you've read through the documentation so you understand the core concepts
2. Create a new branch to work on: `git checkout -b <some-branch-name>`
3. Commit changes by using: `git commit -m 'feat: <short description about the feature>'`
4. Push branch to your fork: `git push origin <some-branch-name>`
5. Finally, create a pull request to the main repository
6. Wait for the PR to be reviewed and merged by the maintainers
5. Finally, create a pull request to the main repository.
6. Wait for the PR to be reviewed and merged by the maintainers.
7. Congratulations! Your name will be shown on the README.md file :tada:
48 changes: 19 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ expediting the amount of time it takes for a submission to be reviewed.

## Getting Started 🚀

1. Your application must first have at least one manifest in [WinGet Community Repository][winget-pkgs-repo]. This
action will take the latest existing manifest as a starting point for the new release. If you still haven't created
and uploaded a manifest, [do that first][create-manifest].
1. Atleast **one** version of your package should already be present in the
[Windows Package Manager Community Repository][winget-pkgs-repo]. The action will use that version as a base to create manifests for new versions of the package.

2. You will need to create a Personal Access Token (PAT) with `public_repo` scope.
2. You will need to create a _classic_ Personal Access Token (PAT) with `public_repo` scope. _New_ fine-grained PATs can't access GitHub's GraphQL API, so they aren't supported by this action. Refer to https://github.com/cli/cli/issues/6680 for more information.

<img src="https://github.com/vedantmgoyal2009/winget-releaser/blob/main/.github/pat-scope.png" alt="Personal Access Token Required Scopes" />

Expand All @@ -32,18 +31,12 @@ expediting the amount of time it takes for a submission to be reviewed.

- Give `workflow` permission to the token you created in Step 1. This will allow the action to automatically update your
fork with the upstream repository.
- You can use *
*[<img src="https://github.com/vedantmgoyal2009/winget-releaser/blob/main/.github/pull-app-logo.svg" valign="bottom"/> Pull App][pull-app-auto-update-forks]
** which keeps your fork up-to-date with the upstream repository via automated pull requests.
- You can use **[<img src="https://github.com/vedantmgoyal2009/winget-releaser/blob/main/.github/pull-app-logo.svg" valign="bottom"/> Pull App][pull-app-auto-update-forks]** which keeps your fork up-to-date with the upstream repository via automated pull requests.

4. Add this action to a GitHub Actions Workflow on your project:
4. Add the action to your workflow file (e.g. `.github/workflows/<name>.yml`). Some quick & important points to note:

- A simple and effective way is to **create a new workflow** that triggers on the [`release` event][release-event]
with [`released` Activity Type][release-activity-type], which means it will fire when a GitHub release is published,
or a pre-release is changed to a release.
- Or you could add this action to an existing workflow, but please note that this action can't be used when the release
is in draft or unpublished status, simply because their binaries are not yet available for general download. The
release must be in **published**, **not-draft** status.
- The action can only be run on Windows runners, so the job must run on `windows-latest`.
- The action will only work when the release is **published** (not a draft), because the release assets (binaries) aren't available publicly until the release is published.

## Examples

Expand All @@ -59,7 +52,7 @@ expediting the amount of time it takes for a submission to be reviewed.
name: Publish to WinGet
on:
release:
types: [ released ]
types: [released]
jobs:
publish:
# Action can only be run on windows
Expand All @@ -68,6 +61,7 @@ jobs:
- uses: vedantmgoyal2009/winget-releaser@v1
with:
identifier: Package.Identifier
max-versions-to-keep: 5 # keep only latest 5 versions
token: ${{ secrets.WINGET_TOKEN }}
```
Expand All @@ -78,7 +72,7 @@ jobs:
name: Publish to WinGet
on:
release:
types: [ released ]
types: [released]
jobs:
publish:
runs-on: windows-latest
Expand All @@ -103,7 +97,7 @@ jobs:
name: Publish to WinGet
on:
release:
types: [ released ]
types: [released]
jobs:
publish:
runs-on: windows-latest
Expand All @@ -129,7 +123,7 @@ jobs:
name: Publish to WinGet
on:
release:
types: [ released ]
types: [released]
jobs:
publish:
runs-on: windows-latest
Expand Down Expand Up @@ -191,14 +185,14 @@ installers-regex: '\.exe$'
## '\.zip$' -> All ZIP's
```

### Delete Previous Version (delete-previous-version)
### Maximum no. of versions to keep in the winget-pkgs repository (max-versions-to-keep)

- Required: ❌ (Default value: `'false'`)
- Required: ❌ (Default value: `0` - unlimited)

Set this to true if you want to overwrite the previous version of the package with the latest version.
The maximum number of versions of the package to keep in the [Windows Package Manager Community Repository][winget-pkgs-repo] repository. If after the current release, the number of versions exceeds this limit, the oldest version will be deleted.

```yaml
delete-previous-version: 'true' # don't forget the quotes
max-versions-to-keep: 5 # keep only the latest 5 versions
```

### Release tag (release-tag)
Expand All @@ -216,22 +210,21 @@ release-tag: ${{ inputs.version }} # workflow_dispatch input `version`
- Required: ✅

The GitHub token with which the action will authenticate with GitHub API and create a pull request on
the [microsoft/winget-pkgs][winget-pkgs-repo] repository.
the [Windows Package Manager Community Repository][winget-pkgs-repo] repository.

```yaml
token: ${{ secrets.WINGET_TOKEN }} # Repository secret called 'WINGET_TOKEN'
```
#### The token should have the `public_repo` scope.

> **Note** Do **not** directly put the token in the action. Instead, create a repository secret containing the token and
> use that in the workflow. See [using encrypted secrets in a workflow][gh-encrypted-secrets] for more details.
> **Note** Do **not** directly put the token in the action. Instead, create a repository secret containing the token and use that in the workflow. See [using encrypted secrets in a workflow][gh-encrypted-secrets] for more details.

### Use fork under which user (fork-user)

- Required: ❌ (Default value: `${{ github.repository_owner }} # repository owner`)

This is the GitHub username of the user where the fork of [microsoft/winget-pkgs][winget-pkgs-repo] is present. This
This is the GitHub username of the user where the fork of [Windows Package Manager Community Repository][winget-pkgs-repo] is present. This
fork will be used to create the pull request.

```yaml
Expand Down Expand Up @@ -281,6 +274,3 @@ Contributions of any kind welcome!
[winget-pkgs-repo]: https://github.com/microsoft/winget-pkgs
[pull-app-auto-update-forks]: https://github.com/wei/pull
[gh-encrypted-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
[create-manifest]: https://learn.microsoft.com/windows/package-manager/package/
[release-event]: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
[release-activity-type]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ inputs:
required: true
description: The regex to match the installers.
default: '.(exe|msi|msix|appx)(bundle){0,1}$'
delete-previous-version:
max-versions-to-keep:
required: true
description: Whether to delete the last version.
default: 'false'
description: 'The maximum number of versions to keep in WinGet Community Repository (Default: 0 - no limit)'
default: '0'
release-repository:
required: true
description: The repository where the release is present (should be present under same user/organization).
Expand Down
Loading

0 comments on commit 9b1e902

Please sign in to comment.