refactor(headless-client): remove FIREZONE_PACKAGE_VERSION (#5487)

Closes #5481 

With this, I can connect to the staging portal without a build.rs or any
extra env var setup

<img width="387" alt="image"
src="https://github.com/firezone/firezone/assets/13400041/9c080b36-3a76-49c7-b706-20723697edc7">


```[tasklist]
### Next steps
- [x] Split out a refactor PR for `ConnectArgs` (#5488)
- [x] Try doing this for other Clients
- [x] Check Gateway
- [x] Check Tauri Client
- [x] Change to `app_version`
- [x] Open for review
- [ ] Use `option_env` so that `FIREZONE_PACKAGE_VERSION` can still override the Cargo.toml version for local testing
- [ ] Check Android Client
- [ ] Check Apple Client
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
This commit is contained in:
Reactor Scram
2024-06-21 23:06:41 +00:00
committed by GitHub
parent 48960d3728
commit 28378fe24e
10 changed files with 11 additions and 18 deletions

View File

@@ -153,8 +153,6 @@ jobs:
artifact: firezone-client-headless-linux
image_name: client
# mark:next-headless-version
version: 1.1.0
# mark:next-headless-version
release_name: headless-client-1.1.0
- package: firezone-relay
artifact: firezone-relay
@@ -163,8 +161,6 @@ jobs:
artifact: firezone-gateway
image_name: gateway
# mark:next-gateway-version
version: 1.1.1
# mark:next-gateway-version
release_name: gateway-1.1.1
- package: snownet-tests
artifact: snownet-tests
@@ -202,9 +198,7 @@ jobs:
PROFILE=""
fi
# Override version by setting it inside cross container if it's provided
${{ matrix.name.version && format('CROSS_CONTAINER_OPTS="--env FIREZONE_PACKAGE_VERSION={0}"', matrix.name.version) }} \
cross build $PROFILE -p ${{ matrix.name.package }} --target ${{ matrix.arch.target }}
cross build $PROFILE -p ${{ matrix.name.package }} --target ${{ matrix.arch.target }}
# Used for Docker images
cp target/${{ matrix.arch.target }}/${{ inputs.profile }}/${{ matrix.name.package }} ${{ matrix.name.package }}

View File

@@ -50,8 +50,6 @@ jobs:
- run: touch local.properties
- name: Bundle and sign release
env:
# mark:next-android-version
FIREZONE_PACKAGE_VERSION: 1.1.0
KEYSTORE_BASE64: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_PASSWORD }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_KEY_PASSWORD }}

View File

@@ -95,8 +95,6 @@ jobs:
ONLY_ACTIVE_ARCH: no
# Needed because `productbuild` doesn't support picking this up automatically like Xcode does
INSTALLER_CODE_SIGN_IDENTITY: "3rd Party Mac Developer Installer: Firezone, Inc. (47R2M6779T)"
# mark:next-apple-version
FIREZONE_PACKAGE_VERSION: 1.1.0
run: |
# Use the same Xcode version as development
sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app

View File

@@ -49,8 +49,6 @@ jobs:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}
# mark:next-gui-version
FIREZONE_PACKAGE_VERSION: 1.1.0
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node

View File

@@ -381,6 +381,7 @@ fn connect(
sockets,
private_key,
os_version_override: Some(os_version),
app_version: env!("CARGO_PKG_VERSION").to_string(),
callbacks,
max_partition_time: Some(MAX_PARTITION_TIME),
};

View File

@@ -196,6 +196,7 @@ impl WrappedSession {
sockets: Sockets::new(),
private_key,
os_version_override,
app_version: env!("CARGO_PKG_VERSION").to_string(),
callbacks: CallbackHandler {
inner: Arc::new(callback_handler),
},

View File

@@ -38,6 +38,7 @@ pub struct ConnectArgs<CB> {
pub sockets: Sockets,
pub private_key: StaticSecret,
pub os_version_override: Option<String>,
pub app_version: String,
pub callbacks: CB,
pub max_partition_time: Option<Duration>,
}
@@ -113,6 +114,7 @@ where
sockets,
private_key,
os_version_override,
app_version,
callbacks,
max_partition_time,
} = args;
@@ -121,7 +123,7 @@ where
let portal = PhoenixChannel::connect(
Secret::new(url),
get_user_agent(os_version_override),
get_user_agent(os_version_override, &app_version),
PHOENIX_TOPIC,
(),
ExponentialBackoffBuilder::default()

View File

@@ -51,7 +51,7 @@ pub fn keypair() -> (StaticSecret, PublicKey) {
(private_key, public_key)
}
pub fn get_user_agent(os_version_override: Option<String>) -> String {
pub fn get_user_agent(os_version_override: Option<String>, app_version: &str) -> String {
// Note: we could switch to sys-info and get the hostname
// but we lose the arch
// and neither of the libraries provide the kernel version.
@@ -67,9 +67,8 @@ pub fn get_user_agent(os_version_override: Option<String>) -> String {
let os_version = os_version_override.unwrap_or(info.version().to_string());
let additional_info = additional_info();
let version = option_env!("FIREZONE_PACKAGE_VERSION").unwrap_or("development");
let lib_name = LIB_NAME;
format!("{os_type}/{os_version}{additional_info}{lib_name}/{version}")
format!("{os_type}/{os_version}{additional_info}{lib_name}/{app_version}")
}
fn additional_info() -> String {

View File

@@ -102,7 +102,7 @@ async fn run(login: LoginUrl, private_key: StaticSecret) -> Result<Infallible> {
let (portal, init) = phoenix_channel::init::<_, InitGateway, _, _>(
Secret::new(login),
get_user_agent(None),
get_user_agent(None, env!("CARGO_PKG_VERSION")),
PHOENIX_TOPIC,
(),
ExponentialBackoffBuilder::default()

View File

@@ -288,6 +288,7 @@ pub fn run_only_headless_client() -> Result<()> {
sockets: Sockets::new(),
private_key,
os_version_override: None,
app_version: env!("CARGO_PKG_VERSION").to_string(),
callbacks,
max_partition_time,
};
@@ -563,6 +564,7 @@ impl Handler {
sockets: Sockets::new(),
private_key,
os_version_override: None,
app_version: env!("CARGO_PKG_VERSION").to_string(),
callbacks: self.callback_handler.clone(),
max_partition_time: Some(Duration::from_secs(60 * 60 * 24 * 30)),
};