diff --git a/.github/workflows/auto_publish.yml b/.github/workflows/auto_publish.yml new file mode 100644 index 0000000..b53dd92 --- /dev/null +++ b/.github/workflows/auto_publish.yml @@ -0,0 +1,23 @@ +name: Chocolatey Publish Pulsar Package + +on: + workflow_dispatch: + +jobs: + publish: + runs-on: windows-latest + + steps: + - name: Checkout Latest Code + uses: actions/checkout@v3 + + - name: Build Package + run: | + cd ./pulsar + choco pack + + - name: Publish New Version + run: | + $fileName = ( Get-ChildItem -Path . -Filter pulsar.*.nupkg ) + Write-Host "Publishing $fileName to Chocolatey" + choco push $fileName --source https://push.chocolatey.org --apikey ${{ github.secrets.CHOCO_API_KEY }} diff --git a/.github/workflows/draft_publish.yml b/.github/workflows/draft_publish.yml new file mode 100644 index 0000000..73e21b3 --- /dev/null +++ b/.github/workflows/draft_publish.yml @@ -0,0 +1,36 @@ +name: Chocolatey Draft Publish Pulsar + +on: + issues: + types: [ labeled ] + +jobs: + draft_publish: + if: contains(github.event.issue.labels.*.name, 'release') + runs-on: windows-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout Latest Code + uses: actions/checkout@v3 + + - name: Install Python Requirements + run: pip install requests + + - name: Init New Version + run: python init.py ${{ github.event.issue.title }} + + - name: Create Pull Request With Changes + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Draft ${{ github.event.issue.title }} Release + branch: release-${{ github.event.issue.title }} + delete-branch: true + title: '[${{ github.event.issue.title }}] Draft Release' + body: | + Automated Draft of new Pulsar Chocolatey Release + Will close #${{ github.event.issue.number }} + draft: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ebdc0a7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +name: Chocolatey Test Installation + +on: [ workflow_dispatch, pull_request] + +jobs: + tests: + runs-on: windows-latest + + steps: + - name: Checkout the latest code + uses: actions/checkout@v3 + + - name: Build Current Version + run: | + cd ./pulsar + choco pack + + - name: Install Current Version + run: choco install pulsar --source . + + - name: Put Pulsar On the PATH + run: | + "$env:LOCALAPPDATA\Programs\Pulsar\" >> $env:GITHUB_PATH + "$env:LOCALAPPDATA\Programs\Pulsar\resources\ppm\bin\" >> $env:GITHUB_PATH + + - name: Ensure Installation was successful + id: pulsar-version + run: | + ( + pulsar --version | + ConvertFrom-String -PropertyNames Application,Delimiter,Version | + Where-Object {$_.Application -eq "Pulsar" } | + Select-Object -Property @{n='version'; e={ return "$($PSItem.Application) $($PSItem.Version)" }} + ).version >> $env:GITHUB_STEP_SUMMARY diff --git a/README.md b/README.md index c890bbe..cccb5a4 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,22 @@ pip install requests ## Usage -### init.py +### Automated Releases + +This PR is intended to allow publishing a new Chocolatey release of Pulsar, without ever opening a terminal. +By using the simple steps laid out below: + +1. Create a new issue. + * This issue should contain the exact version you want to publish as it's title. Nothing else. ex. `1.108.0` + * This issue should receive the label `release` (Best practice to add it after creating the issue) +2. A new PR will be created labeled `[] Draft Release` +3. Let automatic tests finish on this PR. Reviewing the workflow summary page will show what version of Pulsar these changes install. Make sure this matches what version you've intended to publish. +4. If all tests pass, merge the automatic PR. +5. With the PR now merged to `main` go ahead and trigger the GitHub Action `auto_publish`. This Action should run and if successful will publish a new version of Pulsar to Chocolatey. + +### Manual Releases + +#### init.py The script will download the Pulsar installer given the input version, and edit a couple of source files accordingly, namely: @@ -50,7 +65,7 @@ One must input the last version available on the website, otherwise the script w Once the script terminates, the package is ready to be generated. -### Package generation +#### Package generation Once the sources are updated, navigate to `pulsar` folder and run: @@ -80,6 +95,8 @@ If everything is ok, request to publish it on Chocolatey website. choco push pulsar.1.103.0.nupkg --source https://push.chocolatey.org/ ``` +--- + ## To do - update package with 'latest' release; wait for a static URL to download installer; no more input parameter (version) needed