Skip to content

Commit

Permalink
Add workflow to automatically release when PRs are merged (rapidsai#311)
Browse files Browse the repository at this point in the history
* add release-all.yml workflow to release on push to branch-* and release tags
* support only building a subset of images when pushing, and optionally when building manually
* rename release.yaml to release-linux.yml
  • Loading branch information
trxcllnt authored May 24, 2024
1 parent a0160c2 commit 7d6ca6e
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 110 deletions.
27 changes: 12 additions & 15 deletions .github/actions/feature-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ name: feature-matrix
description: Determine the feature matrix

inputs:
base_sha:
type: string
default: ""
full_matrix:
type: string
default: 'false'
default: false
file_patterns:
type: string
default: ""

outputs:
features:
Expand All @@ -16,25 +22,16 @@ outputs:
runs:
using: composite
steps:
- id: get-pr-info
if: inputs.full_matrix != 'true'
name: Get PR target branch info
uses: ./.github/actions/get-pr-info

- name: Check if files changed
- id: changes
name: Check if files changed
if: inputs.full_matrix != 'true'
id: changes
uses: tj-actions/[email protected]
with:
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
base_sha: "${{ inputs.base_sha }}"
since_last_remote_commit: "${{ inputs.base_sha == '' && 'true' || 'false' }}"
files: |
features/src/**
features/test/**
.github/workflows/test.yml
.github/actions/feature-matrix/action.sh
.github/actions/feature-matrix/action.yml
.github/workflows/build-and-test-feature.yml
.github/actions/build-and-test-feature/action.yml
${{ inputs.file_patterns }}
- name: Report changes
if: inputs.full_matrix != 'true'
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/image-matrix/action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ linux_images="$(\
| (.name | split("/")[-1] | split(":")[0]) + (.version // "" | tostring))
)
| (. + [$os])
| join(" "),
| join("-"),
}
)
)
Expand Down Expand Up @@ -101,7 +101,7 @@ if `# Include all images if full_matrix is true` \
| (.name | split("/")[-1] | split(":")[0]) + (.version // "" | tostring))
)
| (. + [$os])
| join(" "),
| join("-"),
}
)
)
Expand Down
32 changes: 14 additions & 18 deletions .github/actions/image-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: image-matrix
description: Determine the image matrix

inputs:
base_sha:
type: string
default: ""
features:
type: string
required: false
Expand All @@ -11,7 +14,10 @@ inputs:
required: false
full_matrix:
type: string
default: 'true'
default: true
file_patterns:
type: string
default: ""

outputs:
linux:
Expand All @@ -22,28 +28,18 @@ outputs:
runs:
using: composite
steps:
- id: get-pr-info
if: inputs.full_matrix != 'true'
name: Get PR target branch info
uses: ./.github/actions/get-pr-info

- name: Check if files changed
- id: changes
name: Check if files changed
if: inputs.full_matrix != 'true'
id: changes
uses: tj-actions/[email protected]
with:
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
base_sha: "${{ inputs.base_sha }}"
since_last_remote_commit: "${{ inputs.base_sha == '' && 'true' || 'false' }}"
files: |
image/*
windows/**
matrix.yml
.github/actions/build-linux-image/*
.github/actions/build-windows-image/*
.github/actions/image-matrix/*
.github/actions/test-windows-image/*
.github/workflows/test.yml
.github/workflows/build-test-and-push-linux-image.yml
.github/workflows/build-test-and-push-windows-image.yml
windows/**
image/.devcontainer/*
${{ inputs.file_patterns }}
- name: Report changes
if: inputs.full_matrix != 'true'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/build-all-rapids-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ jobs:
|| echo "ok=false" | tee -a $GITHUB_OUTPUT;
build-all-rapids-repos:
name: Build all RAPIDS repos
name: RAPIDS
if: needs.check-event.outputs.ok == 'true'
needs: check-event
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
permissions:
actions: read
packages: read
id-token: write
contents: read
pull-requests: read
with:
arch: '["amd64"]'
cuda: '["12.0", "12.2"]'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/build-and-test-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ on:
inputs:
name:
type: string
required: true
required: false
default: "test"
args:
type: string
required: true

jobs:

test:
name: ${{ inputs.name }} (${{ matrix.arch }})
name: ${{ format(inputs.name, matrix.arch) }}
runs-on: ${{ fromJSON(github.repository != 'rapidsai/devcontainers' && '"ubuntu-latest"' || format('"linux-{0}-cpu4"', matrix.arch)) }}
strategy:
fail-fast: false
Expand All @@ -31,7 +32,7 @@ jobs:
username: ${{ secrets.GPUCIBOT_DOCKERHUB_USER }}
password: ${{ secrets.GPUCIBOT_DOCKERHUB_TOKEN }}

- name: ${{ inputs.name }}
- name: Build and test feature
uses: ./.github/actions/build-and-test-feature
with:
args: "${{ inputs.args }}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-test-and-push-linux-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
push:
type: string
required: false
default: 'false'
default: false
description: Whether to push the image
features:
type: string
Expand All @@ -28,7 +28,7 @@ on:
jobs:

build-test-and-upload:
name: Build (${{ matrix.arch }})
name: ${{ matrix.arch }}
runs-on: ${{ fromJSON(github.repository != 'rapidsai/devcontainers' && '"ubuntu-latest"' || format('"linux-{0}-cpu4"', matrix.arch)) }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

merge-artifacts:
if: inputs.push == 'true'
name: Merge image artifacts
name: Download
needs: build-test-and-upload
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-test-and-push-windows-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
push:
type: string
required: false
default: 'false'
default: false
description: Whether to push the image
features:
type: string
Expand All @@ -28,7 +28,7 @@ on:
jobs:

build-test-and-push:
name: Build (${{ matrix.edition }})
name: ${{ matrix.edition }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Generate feature docs

concurrency:
group: generate-feature-docs-on-${{ github.event_name }}-from-${{ github.ref_name }}
group: generate-feature-docs-from-${{ github.ref_name }}
cancel-in-progress: true

on:
push:
branches:
- branch-*
- "branch-[0-9][0-9].[0-9][0-9]"
tags:
- "v[0-9][0-9].[0-9][0-9].[0-9][0-9]"

jobs:
docs:
Expand All @@ -29,9 +31,9 @@ jobs:
- name: Generate feature docs
uses: devcontainers/action@v1
with:
generate-docs: "true"
publish-features: "false"
disable-repo-tagging: "true"
generate-docs: true
publish-features: false
disable-repo-tagging: true
base-path-to-features: "./features/src"
features-namespace: "${{ github.repository }}/features"

Expand All @@ -54,7 +56,7 @@ jobs:
git add */**/README.md;
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true;
# Push updates
if [ "$NO_UPDATES" != "true" ] ; then
if [ "$NO_UPDATES" != 'true' ] ; then
git push origin "$branch";
gh pr create --base "$base" --title "$message" --body "$message";
fi
6 changes: 3 additions & 3 deletions .github/workflows/release-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- name: Release features
uses: devcontainers/action@v1
with:
generate-docs: "true"
publish-features: "true"
disable-repo-tagging: "true"
generate-docs: true
publish-features: true
disable-repo-tagging: true
base-path-to-features: "./features/src"
features-namespace: "${{ github.repository }}/features"
env:
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/release-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release Linux

concurrency:
group: release-linux-from-${{ github.ref_name }}
cancel-in-progress: true

on:
workflow_dispatch:

jobs:

features-matrix:
name: Determine features matrix
runs-on: ubuntu-latest
outputs:
features: "${{ steps.matrix.outputs.features }}"
scenarios: "${{ steps.matrix.outputs.scenarios }}"
steps:
- name: "Checkout ${{ github.repository }}"
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Copy common scripts into features
uses: ./.github/actions/copy-common-scripts

- id: matrix
name: Determine features matrix
uses: ./.github/actions/feature-matrix
with:
full_matrix: true

image-matrix:
name: Determine image matrix
needs: features-matrix
runs-on: ubuntu-latest
outputs:
linux: ${{ steps.matrix.outputs.linux }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- id: matrix
name: Determine image matrix
uses: ./.github/actions/image-matrix
with:
features: "${{ needs.features-matrix.outputs.features }}"
scenarios: "${{ needs.features-matrix.outputs.scenarios }}"
full_matrix: true

release-linux:
if: needs.image-matrix.outputs.linux != '{"include":[]}'
name: ${{ matrix.name }}
needs: image-matrix
secrets: inherit
uses: ./.github/workflows/build-test-and-push-linux-image.yml
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.image-matrix.outputs.linux) }}
with:
push: true
os: "${{ matrix.os }}"
features: "${{ toJSON(matrix.features) }}"
container_env: "${{ toJSON(matrix.env) }}"
repo: "${{ vars.DOCKERHUB_REPOSITORY || github.repository }}"
9 changes: 5 additions & 4 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release Windows

concurrency:
group: release-windows-on-${{ github.event_name }}-from-${{ github.ref_name }}
group: release-windows-from-${{ github.ref_name }}
cancel-in-progress: true

on:
Expand All @@ -25,9 +25,10 @@ jobs:
name: Determine image matrix
uses: ./.github/actions/image-matrix
with:
full_matrix: 'true'
full_matrix: true

build-and-push-windows-images:
release-windows:
if: needs.image-matrix.outputs.windows != '{"include":[]}'
name: ${{ matrix.name }}
needs: image-matrix
secrets: inherit
Expand All @@ -36,7 +37,7 @@ jobs:
fail-fast: false
matrix: ${{ fromJSON(needs.image-matrix.outputs.windows) }}
with:
push: 'true'
push: true
os: "${{ matrix.os }}"
features: "${{ toJSON(matrix.features) }}"
container_env: "${{ toJSON(matrix.env) }}"
Expand Down
Loading

0 comments on commit 7d6ca6e

Please sign in to comment.