Improve nightly release (#3171)
This commit is contained in:
parent
a568dea653
commit
a9eaaebb42
83
.github/workflows/nightly.yml
vendored
83
.github/workflows/nightly.yml
vendored
@ -11,9 +11,28 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check_recent_commit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check Recent Commit
|
||||||
|
outputs:
|
||||||
|
should_run: ${{ steps.should_run.outputs.should_run }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- id: should_run
|
||||||
|
name: Check if latest commit date is within the previous 24 hours
|
||||||
|
run: |
|
||||||
|
if [ -z "$(git rev-list --since="24 hours ago" --all)" ]; then
|
||||||
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
build_nightly:
|
build_nightly:
|
||||||
runs-on: [self-hosted, Windows]
|
runs-on: [self-hosted, Windows]
|
||||||
name: Build Nightly
|
name: Build Nightly
|
||||||
|
needs: check_recent_commit
|
||||||
|
if: needs.check_recent_commit.outputs.should_run == 'true'
|
||||||
outputs:
|
outputs:
|
||||||
full_sha: ${{ steps.var.outputs.full_sha }}
|
full_sha: ${{ steps.var.outputs.full_sha }}
|
||||||
short_sha: ${{ steps.var.outputs.short_sha }}
|
short_sha: ${{ steps.var.outputs.short_sha }}
|
||||||
@ -50,28 +69,55 @@ jobs:
|
|||||||
echo "full_sha=$(git rev-parse HEAD)" >> $env:GITHUB_OUTPUT
|
echo "full_sha=$(git rev-parse HEAD)" >> $env:GITHUB_OUTPUT
|
||||||
echo "short_sha=$(git rev-parse --short HEAD)" >> $env:GITHUB_OUTPUT
|
echo "short_sha=$(git rev-parse --short HEAD)" >> $env:GITHUB_OUTPUT
|
||||||
|
|
||||||
check_date:
|
recreate_release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check latest commit
|
name: Recreate Release
|
||||||
needs: build_nightly
|
needs: build_nightly
|
||||||
outputs:
|
if: needs.check_recent_commit.outputs.should_run == 'true'
|
||||||
should_run: ${{ steps.should_run.outputs.should_run }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- id: should_run
|
- name: Delete Existing Release
|
||||||
continue-on-error: true
|
id: delete_release
|
||||||
name: Check if latest commit date is within the previous 24 hours
|
uses: actions/github-script@v6
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
with:
|
||||||
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT
|
script: |
|
||||||
|
const owner = context.repo.owner;
|
||||||
|
const repo = context.repo.repo;
|
||||||
|
const tag = "nightly";
|
||||||
|
|
||||||
|
// List all releases and find the release by tag
|
||||||
|
const releases = await github.rest.repos.listReleases({
|
||||||
|
owner: owner,
|
||||||
|
repo: repo,
|
||||||
|
});
|
||||||
|
|
||||||
|
const release = releases.data.find(release => release.tag_name === tag);
|
||||||
|
|
||||||
|
// Check if the release exists and delete it
|
||||||
|
if (release) {
|
||||||
|
await github.rest.repos.deleteRelease({
|
||||||
|
owner: owner,
|
||||||
|
repo: repo,
|
||||||
|
release_id: release.id,
|
||||||
|
});
|
||||||
|
console.log(`Deleted release with ID ${release.id}`);
|
||||||
|
} else {
|
||||||
|
console.log("No existing release to delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the tag
|
||||||
|
try {
|
||||||
|
await github.rest.git.deleteRef({
|
||||||
|
owner: owner,
|
||||||
|
repo: repo,
|
||||||
|
ref: `tags/${tag}`,
|
||||||
|
});
|
||||||
|
console.log(`Deleted tag ${tag}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error deleting tag: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
create_release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Create Release
|
|
||||||
needs: [ check_date, build_nightly ]
|
|
||||||
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Download Artifact
|
- name: Download Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@ -84,11 +130,6 @@ jobs:
|
|||||||
echo "build_sha=$(cat sha256.checksum)" >> $GITHUB_OUTPUT
|
echo "build_sha=$(cat sha256.checksum)" >> $GITHUB_OUTPUT
|
||||||
cat sha256.checksum
|
cat sha256.checksum
|
||||||
|
|
||||||
- name: Run latest-tag
|
|
||||||
uses: EndBug/latest-tag@84c87607fcb948bcef069c9a27445e653113979f
|
|
||||||
with:
|
|
||||||
ref: nightly
|
|
||||||
|
|
||||||
- name: Nightly Release
|
- name: Nightly Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
Reference in New Issue
Block a user