Prefer downloaded bridge artifact during deploy

This commit is contained in:
Haitao Pan 2026-04-10 18:00:50 +08:00
parent bbeaa1c992
commit 68d4554be7
2 changed files with 26 additions and 0 deletions

View File

@ -13,6 +13,7 @@ xworkmate_bridge_listen_port: 8787
xworkmate_bridge_binary_path: /usr/local/bin/xworkmate-bridge
xworkmate_bridge_local_source_dir: "{{ playbook_dir }}/../xworkmate-bridge"
xworkmate_bridge_local_build_dir: "{{ playbook_dir }}/.artifacts/xworkmate_bridge"
xworkmate_bridge_artifact_path: "{{ lookup('ansible.builtin.env', 'XWORKMATE_BRIDGE_ARTIFACT_PATH') | default('', true) }}"
xworkmate_bridge_local_binary_path: "{{ xworkmate_bridge_local_build_dir }}/xworkmate-bridge"
xworkmate_bridge_build_goos: linux
xworkmate_bridge_build_goarch: amd64

View File

@ -12,6 +12,26 @@
delegate_to: localhost
become: false
- name: Check whether prebuilt xworkmate-bridge artifact exists
ansible.builtin.stat:
path: "{{ xworkmate_bridge_artifact_path }}"
register: xworkmate_bridge_artifact_stat
delegate_to: localhost
become: false
when:
- xworkmate_bridge_artifact_path | trim | length > 0
- name: Prefer downloaded xworkmate-bridge artifact
ansible.builtin.copy:
src: "{{ xworkmate_bridge_artifact_path }}"
dest: "{{ xworkmate_bridge_local_binary_path }}"
mode: "0755"
delegate_to: localhost
become: false
when:
- xworkmate_bridge_artifact_path | trim | length > 0
- xworkmate_bridge_artifact_stat.stat.exists | default(false)
- name: Build xworkmate-bridge locally
ansible.builtin.command:
cmd: go build -o "{{ xworkmate_bridge_local_binary_path }}" .
@ -24,6 +44,11 @@
delegate_to: localhost
become: false
check_mode: false
when:
- not (
xworkmate_bridge_artifact_path | trim | length > 0 and
xworkmate_bridge_artifact_stat.stat.exists | default(false)
)
- name: Upload xworkmate-bridge binary
ansible.builtin.copy: