mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
gha: move release commands into it's own script
This commit is contained in:
27
.github/workflows/c-cpp.yml
vendored
27
.github/workflows/c-cpp.yml
vendored
@@ -120,28 +120,5 @@ jobs:
|
||||
- name: Remove old release, fetch artifacts, repackage binaries and upload new release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
|
||||
run: |
|
||||
gh release delete "$RELEASE_TAG" \
|
||||
--yes \
|
||||
--cleanup-tag \
|
||||
--repo "$GITHUB_REPOSITORY" || true
|
||||
gh run download "$GITHUB_RUN_ID" \
|
||||
--dir artifacts/ \
|
||||
--repo "$GITHUB_REPOSITORY"
|
||||
pushd artifacts/
|
||||
echo "Found artifacts:"
|
||||
ls
|
||||
for i in $(find -mindepth 1 -maxdepth 1 -type d); do
|
||||
mv "$i"/* .
|
||||
rm -rf "$i"
|
||||
done
|
||||
echo "Repackaged artifacts:"
|
||||
ls -R
|
||||
popd
|
||||
sleep 20s
|
||||
gh release create "$RELEASE_TAG" artifacts/* \
|
||||
--title "Xash3D FWGS Continuous ${{ github.ref_name }} Build" \
|
||||
--target $GITHUB_SHA \
|
||||
--repo "$GITHUB_REPOSITORY" \
|
||||
--prerelease
|
||||
BASE_BUILDNUM_DATE: "2015-04-01"
|
||||
run: bash scripts/gha/make_release.sh "Xash3D FWGS" "${{ github.ref_name }}"
|
||||
|
||||
59
scripts/gha/make_release.sh
Normal file
59
scripts/gha/make_release.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! command -v gh > /dev/null; then
|
||||
echo "Install GitHub CLI tool"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_NAME=$1
|
||||
BRANCH_NAME=$2
|
||||
DEFAULT_BRANCH_NAME=master
|
||||
|
||||
if [ -z "$RELEASE_NAME" ] || [ -z "$BRANCH_NAME" ]; then
|
||||
echo "Invalid arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$BRANCH_NAME" == "$DEFAULT_BRANCH_NAME" ]; then
|
||||
RELEASE_TAG="continuous"
|
||||
else
|
||||
RELEASE_TAG="continuous-$BRANCH_NAME"
|
||||
fi
|
||||
|
||||
gh release delete "$RELEASE_TAG" \
|
||||
--yes \
|
||||
--cleanup-tag \
|
||||
--repo "$GITHUB_REPOSITORY" || true
|
||||
|
||||
gh run download "$GITHUB_RUN_ID" \
|
||||
--dir artifacts/ \
|
||||
--repo "$GITHUB_REPOSITORY"
|
||||
|
||||
pushd artifacts/ || exit 1
|
||||
echo "Found artifacts:"
|
||||
ls
|
||||
for i in $(find -mindepth 1 -maxdepth 1 -type d); do
|
||||
mv "$i"/* .
|
||||
rm -rf "$i"
|
||||
done
|
||||
echo "Repackaged artifacts:"
|
||||
ls -R
|
||||
popd || exit 1
|
||||
|
||||
echo "Generated notes:"
|
||||
rm release-notes && touch release-notes
|
||||
if [ -n "$BASE_BUILDNUM_DATE" ]; then
|
||||
LAST_COMMIT_DATE=$(git log -1 --format=%ci)
|
||||
BUILDNUM=$(( ( $(date -d "$LAST_COMMIT_DATE" +%s ) - $(date -d "$BASE_BUILDNUM_DATE" +%s) ) / 86400 ))
|
||||
echo "buildnum $BUILDNUM" | tee -a release-notes
|
||||
fi
|
||||
|
||||
sleep 20s
|
||||
gh release create "$RELEASE_TAG" artifacts/* \
|
||||
--title "$RELEASE_NAME Continuous $BRANCH_NAME Build" \
|
||||
--notes-file release-notes \
|
||||
--target "$GITHUB_SHA" \
|
||||
--repo "$GITHUB_REPOSITORY" \
|
||||
--prerelease
|
||||
|
||||
rm release-notes
|
||||
Reference in New Issue
Block a user