Skip to content

Commit

Permalink
fix: update-version.sh can now be told version to set
Browse files Browse the repository at this point in the history
Signed-off-by: Gerard Hickey <[email protected]>
  • Loading branch information
hickey committed Feb 12, 2024
1 parent 71c1f9e commit 409c105
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-meshchat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
6 changes: 4 additions & 2 deletions .release-it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 24 additions & 20 deletions package/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 409c105

Please sign in to comment.