Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: xu yang <[email protected]>
  • Loading branch information
JasonYangShadow committed Apr 22, 2024
1 parent 6a9e161 commit aa4864f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
34 changes: 11 additions & 23 deletions .github/actions/generate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: 'Generate warewulf metadata'
description: 'Generate warewulf.spec and dist, collect commits info'

inputs:
nightly:
description: "Whether it is nightly release"
required: true
default: 'false'
token:
description: "Github token"
required: true
Expand All @@ -29,14 +25,15 @@ runs:
steps:
- name: Extract current branch tag
run: |
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "BRANCH=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "TAG=`./script/get-version.sh`" >> $GITHUB_ENV
shell: bash

- name: Extract last 24 hours commits info
id: commits
run: |
echo "raw=`git reflog ${{ env.TAG }} --since="24 hours ago"`" >> $GITHUB_OUTPUT
echo "commits=`git log ${{ env.TAG }} --pretty --since="24 hours ago" | jq --raw-input . | jq --slurp . | jq -c .`" >> $GITHUB_OUTPUT
echo "raw=`git reflog ${{ env.BRANCH }} --since="24 hours ago"`" >> $GITHUB_OUTPUT
echo "commits=`git log ${{ env.BRANCH }} --pretty --since="24 hours ago" | jq --raw-input . | jq --slurp . | jq -c .`" >> $GITHUB_OUTPUT
shell: bash

- name: Whether should continue
Expand All @@ -50,13 +47,13 @@ runs:
shell: bash

- name: Build spec and dist
if: inputs.nightly == 'false' || inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
run: |
make warewulf.spec dist
shell: bash

- name: Set DIST
if: inputs.nightly == 'false' || inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
id: dist
run: |
dist="warewulf-${{ env.TAG }}.tar.gz"
Expand All @@ -76,30 +73,21 @@ runs:
shell: bash

- name: Upload warewulf.spec
if: inputs.nightly == 'false' || inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
uses: actions/upload-artifact@v3
with:
name: warewulf.spec
path: warewulf.spec

- name: Upload DIST
if: inputs.nightly == 'false' || inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ env.DIST }}
path: ${{ env.DIST }}

- name: Normal dist release
uses: xresloader/upload-to-github-release@v1
if: inputs.nightly == 'false'
env:
GITHUB_TOKEN: ${{ inputs.token }}
with:
release_id: ${{ inputs.event-id }}
file: ${{ env.DIST }}

- name: Write nightly release content
if: inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
run: |
cat << EOF >> nightly.release.note
THIS IS A NIGHTLY RELEASE
Expand All @@ -116,7 +104,7 @@ runs:

- name: Nightly dist release
uses: xresloader/upload-to-github-release@v1
if: inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
env:
GITHUB_TOKEN: ${{ inputs.token }}
with:
Expand All @@ -129,7 +117,7 @@ runs:
default_release_name: "warewulf nightly release"

- name: Update nightly release content
if: inputs.nightly == 'true' && steps.should-continue.outputs.continue == 'true'
if: steps.should-continue.outputs.continue == 'true'
uses: tubone24/[email protected]
id: release
env:
Expand Down
15 changes: 13 additions & 2 deletions .github/actions/rpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ runs:
GENERIC_RELEASE=$(rpm -q --qf "%{RELEASE}\n" --specfile warewulf.spec | cut -d. -f1)
RPM=warewulf-${VERSION}-${GENERIC_RELEASE}.${{ inputs.dist }}.${{ inputs.arch }}.rpm
SRPM=warewulf-${VERSION}-${GENERIC_RELEASE}.${{ inputs.dist }}.src.rpm
DRACUT=wareful-dracut-${VERSION}-${GENERIC_RELEASE}.${{ inputs.dist }}.noarch.rpm
echo "RPM=${RPM}" >> $GITHUB_ENV
echo "SRPM=${SRPM}" >> $GITHUB_ENV
echo "DRACUT=${DRACUT}" >> $GITHUB_ENV
shell: bash

- name: Build RPMs and run tests
Expand All @@ -77,10 +79,19 @@ runs:
name: ${{ env.SRPM }}
path: /var/lib/mock/${{ inputs.target }}/result/${{ env.SRPM }}

- name: Attach RPM and SRPM to release
- name: Upload dracut RPM
uses: actions/upload-artifact@v3
with:
name: ${{ env.DRACUT }}
path: /var/lib/mock/${{ inputs.target }}/result/${{ env.DRACUT }}
if-no-files-found: 'ignore'
overwrite: true

- name: Attach all files to release
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ inputs.token }}
with:
release_id: ${{ inputs.event-id }}
file: "/var/lib/mock/${{ inputs.target }}/result/${{ env.RPM }};/var/lib/mock/${{ inputs.target }}/result/${{ env.SRPM }}"
file: " warewulf-${{ env.EXPECTED_VERSION }}.tar.gz;/var/lib/mock/${{ inputs.target }}/result/${{ env.RPM }};/var/lib/mock/${{ inputs.target }}/result/${{ env.SRPM }};/var/lib/mock/${{ inputs.target }}/result/${{ env.DRACUT }}"
overwrite: true
5 changes: 2 additions & 3 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: 'main' # only work on 'main' branch
fetch-depth: 0
- uses: ./.github/actions/generate
name: generate warewulf spec, dist and collect commits info
id: generate
with:
nightly: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
event-id: ${{ github.event.release.id }}

Expand Down Expand Up @@ -55,7 +54,7 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: 'main' # only work on 'main' branch
fetch-depth: 0
- uses: ./.github/actions/rpm
name: build rpms
id: rpm
Expand Down

0 comments on commit aa4864f

Please sign in to comment.