-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPipelineExample.yml
83 lines (71 loc) · 3.06 KB
/
PipelineExample.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
name: Create Release
on:
# Allows the pipeline to be triggered on demand
workflow_dispatch:
# Start a new build whenever something is pushed to branch master
push:
branches:
- master
env:
# Configures the name of the finished mmip file
EXTENSION_FILE_NAME: MyAddon
jobs:
build:
# Run this build on a github hosted ubuntu agent
runs-on: ubuntu-latest
steps:
# Checks out the repository into ${{ github.workspace }}
- uses: actions/checkout@v2
# Remove everything we don't want to include in the final addon
- name: Clean up addon directory
shell: pwsh
run: |
Remove-Item -Path "${{ github.workspace }}/.git" -Recurse -Force -Verbose
Remove-Item -Path "${{ github.workspace }}/.github" -Recurse -Force -Verbose
# Reads the version property from the addon's info.json and sets its patch version
# to the run number of the current build and updates the file with the new version number.
# This ensures that each released has a unique version number, preventing accidental collisions
# with already released versions.
- name: Set version
shell: pwsh
run: |
$infoFile = '${{ github.workspace }}/info.json'
$fileContent = Get-Content $infoFile | ConvertFrom-Json
$fileVersion = [Management.Automation.SemanticVersion]::Parse($fileContent.version)
$version = [Management.Automation.SemanticVersion]::new($fileVersion.Major, $fileVersion.Minor, $env:GITHUB_RUN_NUMBER)
Write-Output "Setting version to $version"
"VERSION=$($version.ToString())" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$fileContent.version = $version.ToString()
$fileContent | ConvertTo-Json -Depth 99 | Set-Content $infoFile
Get-Content $infoFile
# Zip all files into an mmip file
- name: Zip Files
run: cd '${{ github.workspace }}' && zip -r ${{ env.EXTENSION_FILE_NAME }}${{ env.VERSION }}.mmip .
# Attach the mmip as artifact to the current build
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: addon
path: ${{ github.workspace }}/${{ env.EXTENSION_FILE_NAME }}${{ env.VERSION }}.mmip
# Create a new draft release
- name: Create Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: true
prerelease: false
# Attach the mmip to the release
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/${{ env.EXTENSION_FILE_NAME }}${{ env.VERSION }}.mmip
asset_name: ${{ env.EXTENSION_FILE_NAME }}${{ env.VERSION }}.mmip
asset_content_type: application/zip