|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + paths-ignore: |
| 6 | + - CHANGELOG.md |
| 7 | + - .vscode/** |
| 8 | + - .github/** |
| 9 | + - images/** |
| 10 | + - tests/** |
| 11 | + - '**.md' |
| 12 | + - '**.yml' |
| 13 | + tags: |
| 14 | + - '**' |
| 15 | + - '!*preview*' |
| 16 | +env: |
| 17 | + buildFolderName: output |
| 18 | + buildArtifactName: output |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write # to create a release |
| 22 | + id-token: write # to use the GitHub OIDC token for authentication |
| 23 | + packages: write # to publish the module to the PowerShell Gallery |
| 24 | + pull-requests: write # to create a pull request for the changelog |
| 25 | + issues: write # to create an issue for the changelog |
| 26 | + actions: write # to allow the workflow to run actions |
| 27 | + checks: write # to allow the workflow to create checks |
| 28 | + statuses: write # to allow the workflow to create statuses |
| 29 | + |
| 30 | +name: Deploy Module |
| 31 | +# This workflow is triggered on push to the main branch and deploys the module to the PowerShell Gallery and creates a GitHub Release. |
| 32 | +jobs: |
| 33 | + Build_Stage_Package_Module: |
| 34 | + name: Package Module |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Checkout Code |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + ref: ${{ github.head_ref }} # checkout the correct branch name |
| 41 | + fetch-depth: 0 |
| 42 | + - name: Install GitVersion |
| 43 | + uses: gittools/actions/gitversion/[email protected] |
| 44 | + with: |
| 45 | + versionSpec: 5.x |
| 46 | + - name: Evaluate Next Version |
| 47 | + uses: gittools/actions/gitversion/[email protected] |
| 48 | + with: |
| 49 | + configFilePath: GitVersion.yml |
| 50 | + - name: Build & Package Module |
| 51 | + shell: pwsh |
| 52 | + run: ./build.ps1 -ResolveDependency -tasks pack |
| 53 | + env: |
| 54 | + ModuleVersion: ${{ env.GITVERSION_MAJORMINORPATCH }} |
| 55 | + - name: Publish Build Artifact |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: ${{ env.buildArtifactName }} |
| 59 | + path: ${{ env.buildFolderName }}/ |
| 60 | + |
| 61 | + Deploy_Stage_Deploy_Module: |
| 62 | + name: Deploy Module |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: |
| 65 | + - Build_Stage_Package_Module |
| 66 | + if: ${{ success() && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} |
| 67 | + steps: |
| 68 | + - name: Checkout Code |
| 69 | + uses: actions/checkout@v3 |
| 70 | + with: |
| 71 | + ref: ${{ github.head_ref }} # checkout the correct branch name |
| 72 | + fetch-depth: 0 |
| 73 | + - name: Download Build Artifact |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + name: ${{ env.buildArtifactName }} |
| 77 | + path: ${{ env.buildFolderName }} |
| 78 | + - name: Publish Release |
| 79 | + shell: pwsh |
| 80 | + run: ./build.ps1 -tasks publish |
| 81 | + env: |
| 82 | + GitHubToken: ${{ secrets.GitHubToken }} |
| 83 | + GalleryApiToken: ${{ secrets.GalleryApiToken }} |
| 84 | + - name: Send Changelog PR |
| 85 | + shell: pwsh |
| 86 | + run: ./build.ps1 -tasks Create_ChangeLog_GitHub_PR |
| 87 | + env: |
| 88 | + GitHubToken: ${{ secrets.GitHubToken }} |
| 89 | + GalleryApiToken: ${{ secrets.GalleryApiToken }} |
| 90 | + ReleaseBranch: main |
| 91 | + MainGitBranch: main |
0 commit comments