Skip to content

Commit 70c6891

Browse files
committed
chore: add staging workflow
Signed-off-by: Prateek Chandra <[email protected]>
1 parent 0e3cd94 commit 70c6891

File tree

4 files changed

+151
-5
lines changed

4 files changed

+151
-5
lines changed

.github/workflows/image.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ on:
44
branches:
55
- develop
66
- 'release/**'
7-
tags:
8-
- 'v[0-9]+.[0-9]+.[0-9]+**'
7+
workflow_call:
8+
inputs:
9+
tag:
10+
description: 'Tag to be released (e.g. v4.2.0)'
11+
required: true
12+
type: string
913

1014
env:
1115
CARGO_TERM_COLOR: always
1216
CARGO_INCREMENTAL: 0
1317
CI: 1
18+
TAG: ${{ inputs.tag }}
1419

1520
jobs:
1621
image-build-push:
@@ -32,5 +37,16 @@ jobs:
3237
with:
3338
username: ${{ secrets.DOCKERHUB_USERNAME }}
3439
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
- name: Login to GHCR
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
3546
- name: Build and push the release images
36-
run: ./scripts/release.sh
47+
run: |
48+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
49+
./scripts/release.sh --tag ${{ inputs.tag }} --registry ghcr.io/openebs/mayastor/dev
50+
elif [[ "${{ github.event_name }}" == "push" ]]; then
51+
./scripts/release.sh
52+
fi

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release Tagging Workflow
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
7+
jobs:
8+
preflight-checks:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
submodules: recursive
16+
17+
- uses: cachix/[email protected]
18+
- name: Pre-populate nix-shell
19+
run: |
20+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
21+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
22+
nix-shell ./utils/dependencies/scripts/staging/shell.nix --pure --run "echo"
23+
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
30+
- name: Validate if the release should be even made
31+
run: |
32+
nix-shell ./utils/dependencies/scripts/staging/shell.nix --pure --run "./utils/dependencies/scripts/staging/validate.sh \
33+
--tag ${{ github.ref_name }} \
34+
--type release"
35+
36+
release-images:
37+
runs-on: ubuntu-latest
38+
needs: preflight-checks
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
submodules: recursive
45+
46+
- uses: cachix/[email protected]
47+
- name: Pre-populate nix-shell
48+
run: |
49+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
50+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
51+
nix-shell ./utils/dependencies/scripts/staging/shell.nix --pure --run "echo"
52+
53+
- name: Login to Docker Hub
54+
uses: docker/login-action@v3
55+
with:
56+
username: ${{ secrets.DOCKERHUB_USERNAME }}
57+
password: ${{ secrets.DOCKERHUB_TOKEN }}
58+
59+
- name: Login to GHCR
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Mirror images from dev to Docker Hub
67+
run: |
68+
nix-shell ./utils/dependencies/scripts/staging/shell.nix --pure --run "./utils/dependencies/scripts/staging/mirror-images.sh \
69+
--source ghcr.io/${{ github.repository_owner }}/mayastor/dev \
70+
--target docker.io/${{ github.repository_owner }} \
71+
--tag ${{ github.ref_name }}"

.github/workflows/staging.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Staging Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag to be released (e.g. v4.2.0)'
8+
required: true
9+
type: string
10+
11+
env:
12+
TAG: ${{ inputs.tag }}
13+
CI: 1
14+
15+
jobs:
16+
preflight-checks:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
submodules: recursive
24+
25+
- uses: cachix/[email protected]
26+
- name: Pre-populate nix-shell
27+
run: |
28+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
29+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
30+
nix-shell ./utils/dependencies/scripts/staging/shell.nix --pure --run "echo"
31+
32+
- name: Login to
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ secrets.REGISTRY_USERNAME }}
36+
password: ${{ secrets.REGISTRY_PASSWORD }}
37+
38+
- name: Validate if the staging should be even made
39+
run: |
40+
nix-shell ./utils/dependencies/scripts/staging/shell.nix \
41+
--pure \
42+
--keep CI \
43+
--keep TAG \
44+
--run "./utils/dependencies/scripts/staging/validate.sh \
45+
--tag ${{ env.TAG }} \
46+
--type staging"
47+
48+
build-images:
49+
uses: ./.github/workflows/image.yml
50+
needs: preflight-checks
51+
with:
52+
tag: ${{ inputs.tag }}
53+
secrets: inherit

scripts/release.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
# The script assumes that a user is logged on to dockerhub for public images,
66
# or has insecure registry access setup for CI.
77

8-
SOURCE_REL=$(dirname "$0")/../utils/dependencies/scripts/release.sh
8+
# Allow override from caller
9+
if [[ -z "${SOURCE_REL:-}" ]]; then
10+
SOURCE_REL=$(dirname "$0")/../utils/dependencies/scripts/release.sh
11+
fi
912

1013
if [ ! -f "$SOURCE_REL" ] && [ -z "$CI" ]; then
1114
git submodule update --init --recursive
@@ -14,6 +17,9 @@ fi
1417
IMAGES="mayastor.io-engine mayastor.casperf fio-spdk"
1518
CARGO_DEPS=units.cargoDeps
1619
PROJECT="io-engine"
20+
1721
. "$SOURCE_REL"
1822

19-
common_run $@
23+
if [ "${NO_RUN:-}" != "true" ]; then
24+
common_run "$@"
25+
fi

0 commit comments

Comments
 (0)