Skip to content

Commit

Permalink
Take version from Cargo workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
kiron1 committed Nov 25, 2023
1 parent 56bace5 commit b2ec764
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 17 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ jobs:

- name: Bump version of proxydetox
run: |
cargo set-version -p proxydetox --bump ${{ github.event.inputs.release_kind }}
- name: Bump version of proxydetoxlib
run: |
cargo set-version -p proxydetoxlib --bump ${{ github.event.inputs.release_kind }}
cargo set-version --bump ${{ github.event.inputs.release_kind }}
- name: Cargo update
run: |
Expand Down
2 changes: 1 addition & 1 deletion Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "e302a457b3af788bf6dce8fd8332f60f03bab15bbcf6417fd44d7f5f229bee16",
"checksum": "22d22f6b590924a1790efc5085aa9264c7b95a24746492ed2aec8c3d66b620df",
"crates": {
"addr2line 0.21.0": {
"name": "addr2line",
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ default-members = [
"spnego",
]

[workspace.package]
version = "0.7.3"
edition = "2021"
homepage = "https://proxydetox.colorto.cc/"

[workspace.dependencies]
base64 = "0.21"
boa_engine = { version = "0.17", features = ["annex-b"] }
Expand Down
4 changes: 2 additions & 2 deletions proxydetox/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "proxydetox"
version = "0.7.3"
version.workspace = true
edition = "2021"
homepage = "https://proxydetox.colorto.cc/"
homepage.workspace = true

[features]
default = ["negotiate"]
Expand Down
4 changes: 2 additions & 2 deletions proxydetoxlib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "proxydetoxlib"
version = "0.7.3"
version.workspace = true
edition = "2021"
homepage = "https://proxydetox.colorto.cc/"
homepage.workspace = true

[features]
default = ["negotiate"]
Expand Down
6 changes: 3 additions & 3 deletions tools/mkdeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ cargo install \
sed -e "s|\${prefix}|${prefix}|" "${root}/debian/proxydetox.service" \
>"${workdir}/lib/systemd/user/proxydetox.service"

version=$(sed -n 's/^version\s*=\s*"\([0-9.]*\)"/\1/p' "${root}/proxydetox/Cargo.toml")
echo "version=${version}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
version=$("${root}/tools/version" -r)
echo "version=${version}" | tee -a "${GITHUB_OUTPUT:-/dev/stdout}"

pkgfile=proxydetox-${version}-x86_64-${distname}.deb
echo "pkgfile=${pkgfile}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
echo "pkgfile=${pkgfile}" | tee -a "${GITHUB_OUTPUT:-/dev/stdout}"

sed -e "s/\${version}/${version}/" "${root}/debian/control" >"${workdir}/DEBIAN/control"
for f in postinst postrm; do
Expand Down
6 changes: 3 additions & 3 deletions tools/mkpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ install -v -m 0644 "${root}/pkg/macos/40-proxydetox" "${workdir}/etc/paths.d/"
install -d "${workdir}/${prefix}/libexec/"
install -v "${setproxy_helper}" "${workdir}/${prefix}/libexec/setproxy_helper"

version=$(sed -n 's/^version[ \t]*=[ \t]*"\([0-9.]*\)"/\1/p' "${root}/proxydetox/Cargo.toml")
version=$("${root}/tools/version" -r)
pkgfile=proxydetox-${version}-${arch}-apple-darwin.pkg
echo "version=${version}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
echo "pkgfile=${pkgfile}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
echo "version=${version}" | tee -a "${GITHUB_OUTPUT:-/dev/stdout}"
echo "pkgfile=${pkgfile}" | tee -a "${GITHUB_OUTPUT:-/dev/stdout}"

echo "Building ${pkgfile}"
pkgbuild \
Expand Down
22 changes: 21 additions & 1 deletion tools/version
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

set -eu

raw=false

while getopts "r" o; do
case "${o}" in
r)
raw=true
;;
*)
echo "fatal error: invalid arguments"
exit 1
;;
esac
done
shift $((OPTIND - 1))

query=$(printf '.packages[] | {name, version} | select(.name == "%s") | .version' "${1:-proxydetox}")
version=$(cargo metadata --format-version 1 --no-deps --offline --quiet | jq -r "${query}")
echo "version=${version}" >> "${GITHUB_OUTPUT:-/dev/stdout}"

if "${raw}"; then
echo "${version}"
else
echo "version=${version}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
fi

0 comments on commit b2ec764

Please sign in to comment.