diff --git a/.github/workflows/build-meshchat-package.yaml b/.github/workflows/build-meshchat-package.yaml index bd445ba..6b4c713 100644 --- a/.github/workflows/build-meshchat-package.yaml +++ b/.github/workflows/build-meshchat-package.yaml @@ -13,4 +13,6 @@ jobs: - uses: actions/upload-artifact@v3 with: name: meshchat - path: meshchat_* \ No newline at end of file + path: | + meshchat_*.ipk + VERSION \ No newline at end of file diff --git a/package/update-version.sh b/package/update-version.sh index 3fcf16f..5c2f2c8 100755 --- a/package/update-version.sh +++ b/package/update-version.sh @@ -6,19 +6,34 @@ IPK_DIR=$1 -if [[ "$GITHUB_REF_TYPE" == 'tag' ]]; then +if [[ "${GITHUB_REF_TYPE}" == 'tag' ]]; then # ideally should only get version tags (i.e. 'v' followed by a number) if [[ "${GITHUB_REF_NAME}" =~ ^v[0-9].* ]]; then version="${GITHUB_REF_NAME#v}" fi +elif [[ -n "${CI_COMMIT_TAG}" ]]; then + # ideally should only get version tags (i.e. 'v' followed by a number) + if [[ "${CI_COMMIT_TAG}" =~ ^v[0-9].* ]]; then + version="${CI_COMMIT_TAG#v}" + fi else # branch gets date code-branch_name-commit date=$(date +%Y%m%d) branch=$(git rev-parse --abbrev-ref HEAD) + # maybe a detached head, so check common vars for branch name + if [[ -n "${CI_COMMIT_REF_NAME}" ]]; then + branch="${CI_COMMIT_REF_NAME}" + elif [[ -n "${GITHUB_REF_NAME}" ]]; then + branch="${GITHUB_REF_NAME}" + fi commit=$(git rev-parse --short HEAD) version="${date}-${branch}-${commit}" fi +# write the version to a VERSION file +echo "${version}" > VERSION +echo "Updating code references to version ${version}" + sed -i "s/^Version:.*/Version: $version/" $IPK_DIR/CONTROL/control # Update the version in meshchatconfig.lua if present