-
Notifications
You must be signed in to change notification settings - Fork 16
69 lines (66 loc) · 2 KB
/
publish-module.yml
File metadata and controls
69 lines (66 loc) · 2 KB
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
on:
push:
branches:
- main
paths-ignore:
- CHANGELOG.md
- .vscode/**
- .github/**
- images/**
- tests/**
- '**.md'
- '**.yml'
tags:
- '*'
env:
buildFolderName: output
buildArtifactName: output
permissions:
actions: write # to allow the workflow to run actions
checks: write # to allow the workflow to create checks
statuses: write # to allow the workflow to create statuses
name: Deploy Module (only)
# This workflow is triggered on push to the main branch and deploys the module to the PowerShell Gallery and creates a GitHub Release.
jobs:
Build_Stage_Package_Module:
name: Package Module
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the triggered ref (branch or tag)
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Package Module
shell: pwsh
run: ./build.ps1 -ResolveDependency -tasks pack
- name: Publish Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.buildArtifactName }}
path: ${{ env.buildFolderName }}/
Deploy_Stage_Deploy_Module:
name: Deploy Module
runs-on: ubuntu-latest
needs:
- Build_Stage_Package_Module
if: ${{ success() && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the triggered ref (branch or tag)
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.buildArtifactName }}
path: ${{ env.buildFolderName }}
- name: Publish Release
shell: pwsh
run: ./build.ps1 -tasks publish
env:
GitHubToken: ${{ secrets.GitHubToken }}
GalleryApiToken: ${{ secrets.GalleryApiToken }}