|
1 | | -name: Publish Module to PowerShell Gallery |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | | - paths: |
8 | | - - 'PlexAutomationToolkit/PlexAutomationToolkit.psd1' |
9 | | - workflow_dispatch: |
10 | | - |
11 | | -permissions: |
12 | | - contents: write |
13 | | - |
14 | | -jobs: |
15 | | - publish: |
16 | | - name: Publish Module |
17 | | - runs-on: ubuntu-latest |
18 | | - steps: |
19 | | - - name: Checkout |
20 | | - uses: actions/checkout@v6 |
21 | | - with: |
22 | | - fetch-depth: 0 |
23 | | - |
24 | | - - name: Get Module Version |
25 | | - id: version |
26 | | - shell: pwsh |
27 | | - run: | |
28 | | - $manifest = Import-PowerShellDataFile -Path ./PlexAutomationToolkit/PlexAutomationToolkit.psd1 |
29 | | - $version = $manifest.ModuleVersion |
30 | | - Write-Host "Module version: $version" |
31 | | - "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
32 | | -
|
33 | | - - name: Check if Release Exists |
34 | | - id: check_release |
35 | | - shell: bash |
36 | | - env: |
37 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
38 | | - run: | |
39 | | - if gh release view "v${{ steps.version.outputs.version }}" > /dev/null 2>&1; then |
40 | | - echo "exists=true" >> $GITHUB_OUTPUT |
41 | | - echo "GitHub release v${{ steps.version.outputs.version }} already exists" |
42 | | - else |
43 | | - echo "exists=false" >> $GITHUB_OUTPUT |
44 | | - echo "GitHub release v${{ steps.version.outputs.version }} does not exist" |
45 | | - fi |
46 | | -
|
47 | | - - name: Check if PSGallery Version Exists |
48 | | - id: check_psgallery |
49 | | - shell: pwsh |
50 | | - run: | |
51 | | - $version = "${{ steps.version.outputs.version }}" |
52 | | - $published = Find-Module -Name PlexAutomationToolkit -RequiredVersion $version -Repository PSGallery -ErrorAction SilentlyContinue |
53 | | - if ($published) { |
54 | | - Write-Host "PSGallery version $version already exists" |
55 | | - "exists=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
56 | | - } else { |
57 | | - Write-Host "PSGallery version $version not found - will publish" |
58 | | - "exists=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
59 | | - } |
60 | | -
|
61 | | - - name: Bootstrap |
62 | | - if: steps.check_release.outputs.exists == 'false' || steps.check_psgallery.outputs.exists == 'false' |
63 | | - shell: pwsh |
64 | | - run: ./build.ps1 -Task Init -Bootstrap |
65 | | - |
66 | | - - name: Create GitHub Release |
67 | | - if: steps.check_release.outputs.exists == 'false' |
68 | | - shell: bash |
69 | | - env: |
70 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
71 | | - run: | |
72 | | - gh release create "v${{ steps.version.outputs.version }}" \ |
73 | | - --title "v${{ steps.version.outputs.version }}" \ |
74 | | - --generate-notes |
75 | | -
|
76 | | - - name: Publish to PSGallery |
77 | | - if: steps.check_psgallery.outputs.exists == 'false' |
78 | | - shell: pwsh |
79 | | - env: |
80 | | - PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} |
81 | | - run: ./build.ps1 -Task Publish -Bootstrap |
| 1 | +name: Publish Module to PowerShell Gallery |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'PlexAutomationToolkit/PlexAutomationToolkit.psd1' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + name: Publish Module |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v6 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Get Module Version |
| 25 | + id: version |
| 26 | + shell: pwsh |
| 27 | + run: | |
| 28 | + $manifest = Import-PowerShellDataFile -Path ./PlexAutomationToolkit/PlexAutomationToolkit.psd1 |
| 29 | + $version = $manifest.ModuleVersion |
| 30 | + Write-Host "Module version: $version" |
| 31 | + "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 32 | +
|
| 33 | + - name: Check if Release Exists |
| 34 | + id: check_release |
| 35 | + shell: bash |
| 36 | + env: |
| 37 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + run: | |
| 39 | + if gh release view "v${{ steps.version.outputs.version }}" > /dev/null 2>&1; then |
| 40 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 41 | + echo "GitHub release v${{ steps.version.outputs.version }} already exists" |
| 42 | + else |
| 43 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 44 | + echo "GitHub release v${{ steps.version.outputs.version }} does not exist" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Check if PSGallery Version Exists |
| 48 | + id: check_psgallery |
| 49 | + shell: pwsh |
| 50 | + run: | |
| 51 | + $version = "${{ steps.version.outputs.version }}" |
| 52 | + $published = Find-Module -Name PlexAutomationToolkit -RequiredVersion $version -Repository PSGallery -ErrorAction SilentlyContinue |
| 53 | + if ($published) { |
| 54 | + Write-Host "PSGallery version $version already exists" |
| 55 | + "exists=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 56 | + } else { |
| 57 | + Write-Host "PSGallery version $version not found - will publish" |
| 58 | + "exists=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 59 | + } |
| 60 | +
|
| 61 | + - name: Bootstrap |
| 62 | + if: steps.check_release.outputs.exists == 'false' || steps.check_psgallery.outputs.exists == 'false' |
| 63 | + shell: pwsh |
| 64 | + run: ./build.ps1 -Task Init -Bootstrap |
| 65 | + |
| 66 | + - name: Create GitHub Release |
| 67 | + if: steps.check_release.outputs.exists == 'false' |
| 68 | + shell: bash |
| 69 | + env: |
| 70 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: | |
| 72 | + gh release create "v${{ steps.version.outputs.version }}" \ |
| 73 | + --title "v${{ steps.version.outputs.version }}" \ |
| 74 | + --generate-notes |
| 75 | +
|
| 76 | + - name: Publish to PSGallery |
| 77 | + if: steps.check_psgallery.outputs.exists == 'false' |
| 78 | + shell: pwsh |
| 79 | + env: |
| 80 | + PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} |
| 81 | + run: ./build.ps1 -Task Publish -Bootstrap |
0 commit comments