-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.73 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This workflow looks for the latest version of fnm and if the version does not match the latest package version on Chocolatey it will package it and publish it
name: Update
on:
# Every day at 07:00 UTC
schedule:
- cron: "0 7 * * *"
# Allow running manually
workflow_dispatch:
jobs:
# Try to find and create an updated package
package:
runs-on: windows-latest
outputs:
updated: ${{ steps.update-package.outputs.updated }}
version: ${{ steps.update-package.outputs.version }}
steps:
# Check-out repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
# Install Chocolatey AU module
- name: Install AU
run: choco install au -y
shell: powershell
# Run the AU update command
- name: Run AU update
id: update-package
run: |
$result = .\update.ps1
echo "::set-output name=updated::$($result.Updated)"
echo "::set-output name=version::$($result.RemoteVersion)"
working-directory: ./fnm
shell: powershell
# If there is an update then commit changes to repo
- name: Commit update
if: ${{ steps.update-package.outputs.updated == 'True' }}
run: |
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "Update to latest release"
git push
# If there is an update then upload any resulting nupkg as an artifact
- name: Upload nupkg artifact
uses: actions/upload-artifact@v4
if: ${{ steps.update-package.outputs.updated == 'True' }}
with:
name: nupkg
path: ./fnm/*.nupkg
if-no-files-found: error
# If there is an updated package then publish it
publish:
needs: package
if: ${{ needs.package.outputs.updated == 'True' }}
runs-on: windows-latest
steps:
- name: Download nupkg artifact
uses: actions/download-artifact@v4
with:
name: nupkg
# Publish to Chocolatey feed
- name: Push to Chocolatey
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
run: |
choco apikey -k "$env:CHOCO_API_KEY" -source https://push.chocolatey.org/
choco push -s https://push.chocolatey.org/
shell: pwsh
# Push to GitHub releases
- name: Create GitHub Release
uses: softprops/[email protected]
with:
tag_name: ${{ needs.package.outputs.version }}
body: 'Automatic update from latest fnm release.'
files: |
*.nupkg
fail_on_unmatched_files: true