From e557c3fec3bcf79e5c2ad7e6387e46619f416f1c Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sun, 15 Dec 2024 21:54:08 -0700 Subject: [PATCH] Upload onedir artifacts to release --- .github/workflows/draft-release.yml | 66 ++----------------- .github/workflows/release-artifact.yml | 61 +++++++++++++++++ .github/workflows/staging.yml | 2 +- .github/workflows/templates/staging.yml.jinja | 3 +- 4 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/release-artifact.yml diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 1bec8b2d1aa..59a1bdcd210 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -52,80 +52,28 @@ jobs: - name: Release Output run: echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> "$GITHUB_OUTPUT" - list-source-tarball: - name: List Source Tarball Artifacts - needs: - - create-github-release - runs-on: ubuntu-22.04 - outputs: - files: ${{ steps.list-files.outputs.files }} - steps: - - uses: actions/download-artifact@v4 - with: - name: salt-${{ inputs.salt-version }}.tar.gz - path: artifacts - - id: list-files - run: | - echo files="$(find artifacts -maxdepth 1 -type f -printf '%f\n' | jq -Rnc '[inputs | { file: "\(.)" }]')" >> "$GITHUB_OUTPUT" - upload-source-tarball: - name: Upload Source Tarball Artifacts runs-on: ubuntu-22.04 needs: - - list-source-tarball - create-github-release - strategy: - matrix: - include: ${{ fromJSON(needs.list-source-tarball.outputs.files) }} steps: - - uses: actions/download-artifact@v4 + - uses: ./.github/workflows/release-artifact.yml with: name: salt-${{ inputs.salt-version }}.tar.gz - path: artifacts + upload_url: ${{ needs.create-github-release.outputs.upload_url }} - - id: file-type - run: echo "file_type=$( file --mime-type artifacts/${{ matrix.file }} )" >> "$GITHUB_OUTPUT" - - - name: Upload Source Tarball - id: upload-release-asset-source - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-github-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: artifacts/${{ matrix.file }} - asset_name: ${{ matrix.file }} - asset_content_type: ${{ steps.file-type.outputs.file_type }} - - list-onedir-linux: - name: List Onedir Artifacts Linux + upload-onedir: runs-on: ubuntu-22.04 needs: - create-github-release - outputs: - ${{ matrix.arch }}-files: ${{ steps.list-files.outputs.files }} strategy: matrix: - include: ${{ fromJSON(inputs.matrix)['linux'] }} + include: ${{ inputs.matrix }} steps: - - uses: actions/download-artifact@v4 + - uses: ./.github/workflows/release-artifact.yml with: - name: salt-${{ inputs.salt-version }}-onedir-linux-${{ matrix.arch }}.tar.xz - path: artifacts - - id: list-files - run: | - echo ${{ matrix.arch }}-files="$(find artifacts -maxdepth 1 -type f -printf '%f\n' | jq -Rnc '[inputs | { file: "\(.)" }]')" >> "$GITHUB_OUTPUT" - -# upload-onedir-linux: -# name: Upload Onedir Packages Linux -# runs-on: ubuntu-22.04 -# needs: -# - create-github-release -# - list-onedir-linux -# strategy: -# matrix: -# include: ${{ fromJSON(needs.list-onedir-linux.outputs.files) }} - + name: salt-${{ inputs.salt-version }}-onedir-${{ matrix.platform }}-${{ matrix.arch }}.${{ matrix.platform == 'windows' && 'zip' || 'tar.xz' }} + upload_url: ${{ needs.create-github-release.outputs.upload_url }} release-artifacts: name: Download and list all artifacts diff --git a/.github/workflows/release-artifact.yml b/.github/workflows/release-artifact.yml new file mode 100644 index 00000000000..d6a2331e854 --- /dev/null +++ b/.github/workflows/release-artifact.yml @@ -0,0 +1,61 @@ +--- +name: Upload Release Artifact + +on: + workflow_call: + inputs: + artifact-name: + type: string + required: true + description: The Salt version to set prior to building packages. + uload-url: + type: string + required: true + description: Release's upload url. + + +steps: + + list-files: + name: List Files From Artifact + needs: + - create-github-release + runs-on: ubuntu-22.04 + outputs: + files: ${{ steps.list-files.outputs.files }} + steps: + - uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: artifacts + - id: list-files + run: | + echo files="$(find artifacts -maxdepth 1 -type f -printf '%f\n' | jq -Rnc '[inputs | { file: "\(.)" }]')" >> "$GITHUB_OUTPUT" + + upload-files: + name: Upload Source Tarball Artifacts + runs-on: ubuntu-22.04 + needs: + - list-files + strategy: + matrix: + include: ${{ fromJSON(needs.list-files.outputs.files) }} + steps: + - uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: artifacts + + - id: file-type + run: echo "file_type=$( file --mime-type artifacts/${{ matrix.file }} )" >> "$GITHUB_OUTPUT" + + - name: Upload Source Tarball + id: upload-release-asset-source + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: artifacts/${{ matrix.file }} + asset_name: ${{ matrix.file }} + asset_content_type: ${{ steps.file-type.outputs.file_type }} diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 83438ea9565..fc78227aa32 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -665,7 +665,7 @@ jobs: uses: ./.github/workflows/draft-release.yml with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - matrix: ${{ toJSON(fromJSON(needs.prepare-workflow.outputs.config)['build-matrix']) }} + matrix: ${{ toJSON(fromJSON(needs.prepare-workflow.outputs.config)['artifact-matrix']) }} set-pipeline-exit-status: # This step is just so we can make github require this step, to pass checks diff --git a/.github/workflows/templates/staging.yml.jinja b/.github/workflows/templates/staging.yml.jinja index adb42dce1dc..a3d370a704b 100644 --- a/.github/workflows/templates/staging.yml.jinja +++ b/.github/workflows/templates/staging.yml.jinja @@ -194,6 +194,7 @@ concurrency: uses: ./.github/workflows/draft-release.yml with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - matrix: ${{ toJSON(fromJSON(needs.prepare-workflow.outputs.config)['build-matrix']) }} + matrix: ${{ toJSON(fromJSON(needs.prepare-workflow.outputs.config)['artifact-matrix']) }} + <%- endblock jobs %>