From 409c105060fd2ada184736f49831195917f06743 Mon Sep 17 00:00:00 2001 From: Gerard Hickey Date: Mon, 12 Feb 2024 11:02:38 -0500 Subject: [PATCH] fix: update-version.sh can now be told version to set Signed-off-by: Gerard Hickey --- .github/workflows/release-meshchat.yaml | 2 +- .release-it.yaml | 6 ++-- package/update-version.sh | 44 ++++++++++++++----------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release-meshchat.yaml b/.github/workflows/release-meshchat.yaml index 2d8ff09..407f69a 100644 --- a/.github/workflows/release-meshchat.yaml +++ b/.github/workflows/release-meshchat.yaml @@ -57,6 +57,6 @@ jobs: with: name: ${{ needs.release_meshchat_package.outputs.package_file }} path: ${{ needs.release_meshchat_package.outputs.package_file }} - - run: npx release-it --ci --no-git --github.release=false --github.assets=*.dep --github.assets=*.ipk + - run: npx release-it --ci --no-increment --no-git --no-npm --github.update=true --github.assets=${{ needs.release_meshchat_package.outputs.package_file }} env: GITHUB_TOKEN: ${{ secrets.RELEASE_IT_TOKEN }} \ No newline at end of file diff --git a/.release-it.yaml b/.release-it.yaml index f7eacab..92426c9 100644 --- a/.release-it.yaml +++ b/.release-it.yaml @@ -6,14 +6,16 @@ git: tagName: "v${version}" tagAnnotation: "Automated release: ${version}" push: true - #requireBranch: release + requireBranch: release-job requireCommits: true changelog: "npx auto-changelog --stdout --commit-limit false" github: release: true releaseName: "v${version}" - assets: ["*.ipk", "*.deb"] + assets: + - "*.ipk" + - "*.deb" npm: publish: false diff --git a/package/update-version.sh b/package/update-version.sh index 5c2f2c8..9e169c8 100755 --- a/package/update-version.sh +++ b/package/update-version.sh @@ -6,28 +6,32 @@ IPK_DIR=$1 -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 +if [[ -f VERSION ]]; then + version=$(cat VERSION) 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}" + 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 - commit=$(git rev-parse --short HEAD) - version="${date}-${branch}-${commit}" fi # write the version to a VERSION file