Skip to content

Commit

Permalink
Upload onedir artifacts to release
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Dec 16, 2024
1 parent 8ee9285 commit e3aa09b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 63 deletions.
70 changes: 9 additions & 61 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
runs-on: ubunut-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

- 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 }}
upload_url: ${{ needs.create-github-release.outputs.upload_url }}

list-onedir-linux:
name: List Onedir Artifacts Linux
runs-on: ubuntu-22.04
upload-onedir:
runs-on: ubunut-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-varion }}-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
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/release-artifact.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/templates/staging.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

0 comments on commit e3aa09b

Please sign in to comment.