Skip to content

Commit

Permalink
Automates version increment of winget package (#337)
Browse files Browse the repository at this point in the history
This automates updates of the func-e package on winget. This uses
manifest generated locally, so we can control the contents easily.

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Aug 11, 2021
1 parent d488e66 commit 5614f43
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 18 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ on:
env:
GIT_USER_NAME: Tetrate Labs CI
GIT_USER_EMAIL: [email protected]
GIT_COMMITTER: Tetrate Labs CI <[email protected]>

jobs:
homebrew:
Expand All @@ -41,3 +42,60 @@ jobs:
brew bump-formula-pr --no-browse --no-audit --version "${version}" func-e
env: # See env section for notes on PACKAGE_BUMP_TOKEN
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.PACKAGE_BUMP_TOKEN }}

# This job downloads the func-e.msi from the corresponding release. It extracts properties from
# it in order to create a winget package manifest. Finally, it creates a pull request to add the
# new version. The pull request is a branch on tetratelabs/winget-pkgs so that anyone on the team
# can edit it as necessary.
msi:
name: "microsoft/winget-create"
runs-on: ubuntu-latest
steps:
- name: "Checkout func-e"
uses: actions/checkout@v2
with:
path: func-e

- name: "Checkout winget-pkgs"
uses: actions/checkout@v2
with:
repository: microsoft/winget-pkgs
ref: master
path: winget-pkgs

- name: "Write winget manifest"
run: |
tag="${GITHUB_REF#refs/tags/}"
version=${tag#v}
echo "MSI_VERSION=${version}" >> $GITHUB_ENV
cd func-e
gh release download "${tag}" -p '*windows_amd64.msi'
manifest_path=../winget-pkgs/manifests/Tetrate/func-e/${version}/Tetrate.func-e.yaml
mkdir -p $(dirname ${manifest_path})
./packaging/msi/winget_manifest.sh ${version} *windows_amd64.msi > ${manifest_path}
env: # See env section for notes on PACKAGE_BUMP_TOKEN
GITHUB_TOKEN: ${{ secrets.PACKAGE_BUMP_TOKEN }}

- name: "Create winget-pkgs pull request"
uses: peter-evans/create-pull-request@v3
id: winget-pkgs-pr
with:
path: winget-pkgs
branch: func-e-${{ env.MSI_VERSION }}
delete-branch: true
push-to-fork: tetratelabs/winget-pkgs
commit-message: "New version: Tetrate.func-e version ${{ env.MSI_VERSION }}"
committer: ${{ env.GIT_COMMITTER }}
author: ${{ env.GIT_COMMITTER }}
title: "New version: Tetrate.func-e version ${{ env.MSI_VERSION }}"
body: |
- [x] Have you signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs)?
- [x] Have you checked that there aren't other open [pull requests](https://github.com/microsoft/winget-pkgs/pulls) for the same manifest update/change?
- [x] Have you validated your manifest locally with `winget validate --manifest <path>`?
- [x] Have you tested your manifest locally with `winget install --manifest <path>`?
- [x] Does your manifest conform to the [1.0 schema](https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md)?
token: ${{ secrets.PACKAGE_BUMP_TOKEN }}

- name: "Echo winget-pkgs pull request"
run: |
echo ${{ steps.winget-pkgs-pr.outputs.pull-request-url }}
23 changes: 5 additions & 18 deletions .github/workflows/msi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,8 @@ jobs:
key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }}
restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-

- name: "Build Windows Installer (MSI) and generate winget manifest"
# This intentionally defers winget manifest through GH env.
# bump.yaml will check out winget-pkgs repository and write the file there, no longer
# having access to the original files.
#
# Note: generation of winget manifest is cross-platform, but validation requires winget.
run: |
make msi
winget_manifest=$(./packaging/msi/winget_manifest.sh)
echo "WINGET_MANIFEST<<EOF" >> $GITHUB_ENV
echo "$winget_manifest" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: "Build Windows Installer (MSI)"
run: make msi

# This only checks the installer when built on Windows as it is simpler than switching OS.
# refreshenv is from choco, and lets you reload ENV variables (used here for PATH).
Expand All @@ -90,12 +80,9 @@ jobs:
run: call packaging\msi\verify_msi.cmd
shell: cmd

# This tests writing the manifest via GHA env works. Validation requires too much setup.
# This tests the manifest via yamllint because validation via winget requires too much setup.
# See https://github.com/microsoft/winget-cli/issues/754#issuecomment-896475895
- name: "Write winget manifest"
- name: "Test winget manifest generation"
run: |
manifest_path=./Tetrate.func-e.yaml
cat > "${manifest_path}" <<'EOF'
${{ env.WINGET_MANIFEST }}
EOF
./packaging/msi/winget_manifest.sh > Tetrate.func-e.yaml
yamllint -sd '{extends: default, rules: {line-length: disable}}' Tetrate.func-e.yaml

0 comments on commit 5614f43

Please sign in to comment.