|
2 | 2 | name: Create Release Workflow
|
3 | 3 |
|
4 | 4 | on:
|
5 |
| - workflow_call: |
6 |
| - inputs: |
7 |
| - runs-on-config: |
8 |
| - required: true |
9 |
| - type: string |
10 |
| - release-version: |
11 |
| - required: true |
12 |
| - type: string |
13 |
| - is-pre-release: |
14 |
| - required: true |
15 |
| - type: boolean |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + runs-on-config: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + release-version: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + is-pre-release: |
| 14 | + required: true |
| 15 | + type: boolean |
16 | 16 |
|
17 | 17 | jobs:
|
18 |
| - create-release: |
19 |
| - runs-on: ${{ inputs.runs-on-config }} |
20 |
| - name: Create a New Release |
21 |
| - steps: |
22 |
| - - name: Create Release |
23 |
| - id: create-release |
24 |
| - uses: actions/github-script@v7 |
25 |
| - env: |
26 |
| - RELEASE_VERSION: ${{ inputs.release-version }} |
27 |
| - IS_PRERELEASE: ${{ inputs.is-pre-release }} |
28 |
| - with: |
29 |
| - result-encoding: string |
30 |
| - script: | |
31 |
| - const { RELEASE_VERSION, IS_PRERELEASE } = process.env |
| 18 | + create-release: |
| 19 | + runs-on: ${{ inputs.runs-on-config }} |
| 20 | + name: Create a New Release |
| 21 | + steps: |
| 22 | + - name: Create Release |
| 23 | + id: create-release |
| 24 | + uses: actions/github-script@v7 |
| 25 | + env: |
| 26 | + RELEASE_VERSION: ${{ inputs.release-version }} |
| 27 | + IS_PRERELEASE: ${{ inputs.is-pre-release }} |
| 28 | + with: |
| 29 | + result-encoding: string |
| 30 | + script: | |
| 31 | + // Extract environment variables |
| 32 | + const { RELEASE_VERSION, IS_PRERELEASE } = process.env |
32 | 33 |
|
33 |
| - const release_version = `release/${RELEASE_VERSION}` |
34 |
| - const is_prerelease = IS_PRERELEASE === 'true' |
| 34 | + // Define release version and pre-release flag |
| 35 | + const release_version = `release/${RELEASE_VERSION}` |
| 36 | + const is_prerelease = IS_PRERELEASE === 'true' |
35 | 37 |
|
36 |
| - const createReleaseResponse = await github.rest.repos.createRelease({ |
37 |
| - owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
38 |
| - repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
39 |
| - tag_name: release_version, // (Required) The name of the tag. |
40 |
| - target_commitish: context.sha, // (Optional) Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch. |
41 |
| - name: release_version, // (Optional) The name of the release. |
42 |
| - // body: '', // (Optional) Text describing the contents of the tag. |
43 |
| - // draft: true, // (Optional) true to create a draft (unpublished) release, false to create a published one. |
44 |
| - prerelease: is_prerelease, // (Optional) true to identify the release as a prerelease. false to identify the release as a full release. |
45 |
| - // discussion_category_name: , // (Optional) If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see "Managing categories for discussions in your repository." |
46 |
| - // make_latest: false, // (Optional) Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Defaults to true for newly published releases. legacy specifies that the latest release should be determined based on the release creation date and higher semantic version. |
47 |
| - generate_release_notes: true // (Optional) Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. |
48 |
| - }) |
| 38 | + // Create a new release |
| 39 | + const createReleaseResponse = await github.rest.repos.createRelease({ |
| 40 | + owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
| 41 | + repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
| 42 | + tag_name: release_version, // (Required) The name of the tag. |
| 43 | + target_commitish: context.sha, // (Optional) Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch. |
| 44 | + name: release_version, // (Optional) The name of the release. |
| 45 | + // body: '', // (Optional) Text describing the contents of the tag. |
| 46 | + // draft: true, // (Optional) true to create a draft (unpublished) release, false to create a published one. |
| 47 | + prerelease: is_prerelease, // (Optional) true to identify the release as a prerelease. false to identify the release as a full release. |
| 48 | + // discussion_category_name: , // (Optional) If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see "Managing categories for discussions in your repository." |
| 49 | + // make_latest: false, // (Optional) Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Defaults to true for newly published releases. legacy specifies that the latest release should be determined based on the release creation date and higher semantic version. |
| 50 | + generate_release_notes: true // (Optional) Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. |
| 51 | + }) |
49 | 52 |
|
50 |
| - return createReleaseResponse.data.id |
51 |
| - - uses: actions/download-artifact@v4 |
52 |
| - with: |
53 |
| - name: docs |
54 |
| - - uses: actions/download-artifact@v4 |
55 |
| - with: |
56 |
| - name: nuget-package |
57 |
| - - uses: actions/download-artifact@v4 |
58 |
| - with: |
59 |
| - name: pypi-package |
60 |
| - - name: Generate Bundle |
61 |
| - run: | |
62 |
| - zip -r bundle.zip ./Tableau.Migration.${{ inputs.release-version }}.nupkg docs.zip tableau_migration-pypi.zip |
63 |
| - - name: Upload Release Assets |
64 |
| - id: upload-docs |
65 |
| - uses: actions/github-script@v7 |
66 |
| - env: |
67 |
| - RELEASE_VERSION: ${{ inputs.release-version }} |
68 |
| - RELEASE_ID: ${{ steps.create-release.outputs.result }} |
69 |
| - with: |
70 |
| - script: | |
71 |
| - const fs = require('fs') |
72 |
| - |
73 |
| - const { RELEASE_VERSION, RELEASE_ID } = process.env |
| 53 | + // Return the release ID |
| 54 | + return createReleaseResponse.data.id |
| 55 | + - uses: actions/download-artifact@v4 |
| 56 | + with: |
| 57 | + name: docs |
| 58 | + - uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + name: nuget-package |
| 61 | + - uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + name: pypi-package |
| 64 | + - name: Generate Bundle |
| 65 | + run: | |
| 66 | + zip -r bundle.zip ./Tableau.Migration.${{ inputs.release-version }}.nupkg docs.zip tableau_migration-pypi.zip |
| 67 | + - name: Upload Release Assets |
| 68 | + id: upload-docs |
| 69 | + uses: actions/github-script@v7 |
| 70 | + env: |
| 71 | + RELEASE_VERSION: ${{ inputs.release-version }} |
| 72 | + RELEASE_ID: ${{ steps.create-release.outputs.result }} |
| 73 | + with: |
| 74 | + script: | |
| 75 | + const fs = require('fs') |
| 76 | + |
| 77 | + // Extract environment variables |
| 78 | + const { RELEASE_VERSION, RELEASE_ID } = process.env |
74 | 79 |
|
75 |
| - const nuget_package = `Tableau.Migration.${RELEASE_VERSION}.nupkg` |
| 80 | + // Define the NuGet package name |
| 81 | + const nuget_package = `Tableau.Migration.${RELEASE_VERSION}.nupkg` |
76 | 82 |
|
77 |
| - const uploadDocsResponse = await await github.rest.repos.uploadReleaseAsset({ |
78 |
| - owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
79 |
| - repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
80 |
| - release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
81 |
| - name: 'docs.zip', // (Required) |
82 |
| - label: 'Docs (zip)', // (Optional) |
83 |
| - data: fs.readFileSync('./docs.zip') // (Optional) The raw file data. |
84 |
| - }) |
| 83 | + // Upload documentation zip file |
| 84 | + const uploadDocsResponse = await github.rest.repos.uploadReleaseAsset({ |
| 85 | + owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
| 86 | + repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
| 87 | + release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
| 88 | + name: 'docs.zip', // (Required) |
| 89 | + label: 'Docs (zip)', // (Optional) |
| 90 | + data: fs.readFileSync('./docs.zip') // (Optional) The raw file data. |
| 91 | + }) |
85 | 92 |
|
86 |
| - const uploadNugetResponse = await github.rest.repos.uploadReleaseAsset({ |
87 |
| - owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
88 |
| - repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
89 |
| - release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
90 |
| - name: 'Tableau.Migration.nupkg', // (Required) |
91 |
| - label: 'Nuget Package (nupkg)', // (Optional) |
92 |
| - data: fs.readFileSync(nuget_package) // (Optional) The raw file data. |
93 |
| - }) |
| 93 | + // Upload NuGet package |
| 94 | + const uploadNugetResponse = await github.rest.repos.uploadReleaseAsset({ |
| 95 | + owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
| 96 | + repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
| 97 | + release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
| 98 | + name: 'Tableau.Migration.nupkg', // (Required) |
| 99 | + label: 'Nuget Package (nupkg)', // (Optional) |
| 100 | + data: fs.readFileSync(nuget_package) // (Optional) The raw file data. |
| 101 | + }) |
94 | 102 |
|
95 |
| - const uploadPypiResponse = await github.rest.repos.uploadReleaseAsset({ |
96 |
| - owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
97 |
| - repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
98 |
| - release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
99 |
| - name: 'tableau_migration-pypi.zip', // (Required) |
100 |
| - label: 'Pypi Package (zip)', // (Optional) |
101 |
| - data: fs.readFileSync('./tableau_migration-pypi.zip') // (Optional) The raw file data. |
102 |
| - }) |
| 103 | + // Upload PyPI package |
| 104 | + const uploadPypiResponse = await github.rest.repos.uploadReleaseAsset({ |
| 105 | + owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
| 106 | + repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
| 107 | + release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
| 108 | + name: 'tableau_migration-pypi.zip', // (Required) |
| 109 | + label: 'Pypi Package (zip)', // (Optional) |
| 110 | + data: fs.readFileSync('./tableau_migration-pypi.zip') // (Optional) The raw file data. |
| 111 | + }) |
103 | 112 |
|
104 |
| - const uploadBundleResponse = await github.rest.repos.uploadReleaseAsset({ |
105 |
| - owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
106 |
| - repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
107 |
| - release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
108 |
| - name: 'bundle.zip', // (Required) |
109 |
| - label: 'Bundle Package (zip)', // (Optional) |
110 |
| - data: fs.readFileSync('./bundle.zip') // (Optional) The raw file data. |
111 |
| - }) |
| 113 | + // Upload bundle zip file |
| 114 | + const uploadBundleResponse = await github.rest.repos.uploadReleaseAsset({ |
| 115 | + owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. |
| 116 | + repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. |
| 117 | + release_id: RELEASE_ID, // (Required) The unique identifier of the release. |
| 118 | + name: 'bundle.zip', // (Required) |
| 119 | + label: 'Bundle Package (zip)', // (Optional) |
| 120 | + data: fs.readFileSync('./bundle.zip') // (Optional) The raw file data. |
| 121 | + }) |
112 | 122 |
|
113 |
| - return { |
114 |
| - docs: uploadDocsResponse.data, |
115 |
| - nuget: uploadNugetResponse.data, |
116 |
| - pypi: uploadPypiResponse.data, |
117 |
| - bundle: uploadBundleResponse.data |
118 |
| - } |
| 123 | + // Return the upload responses |
| 124 | + return { |
| 125 | + docs: uploadDocsResponse.data, |
| 126 | + nuget: uploadNugetResponse.data, |
| 127 | + pypi: uploadPypiResponse.data, |
| 128 | + bundle: uploadBundleResponse.data |
| 129 | + } |
0 commit comments