-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
90 lines (85 loc) · 3.95 KB
/
.gitlab-ci.yml
File metadata and controls
90 lines (85 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
stages:
- build
- release
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}"
# --- JOB: Build Linux ---
build-linux:
stage: build
image: rust:latest
rules:
- if: $CI_COMMIT_TAG =~ /^v/
script:
- "apt-get update && apt-get install -y jq wget xz-utils file"
- "VERSION=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')"
- "cargo build --release"
- "wget -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
- "chmod +x appimagetool.AppImage"
- "./appimagetool.AppImage --appimage-extract"
- "mv squashfs-root appimagetool"
- "cp -r .github/AppImage AppDir-build"
- "mkdir -p AppDir-build/usr/bin"
- "strip target/release/seedctl || true"
- "cp target/release/seedctl AppDir-build/usr/bin/seedctl"
- "mkdir -p dist"
- "./appimagetool/AppRun AppDir-build dist/seedctl-${VERSION}-linux-x86_64.AppImage"
- "cp target/release/seedctl dist/seedctl-${VERSION}-linux-x86_64"
- "echo $VERSION > dist/version.txt"
artifacts:
paths:
- dist/
# --- JOB: Build Windows ---
build-windows:
stage: build
tags:
- saas-windows-medium-amd64
rules:
- if: $CI_COMMIT_TAG =~ /^v/
script:
- 'Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe"'
- '.\rustup-init.exe -y --default-toolchain stable --default-host x86_64-pc-windows-msvc'
- '$env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"'
- '$VERSION = (Get-Content Cargo.toml | Select-String "^version = `"(.*)`"" | ForEach-Object { $_.Matches.Groups[1].Value })'
- 'cargo build --release'
- 'New-Item -ItemType Directory -Force -Path dist'
- 'Copy-Item "target\release\seedctl.exe" "dist\seedctl-$VERSION-windows-x86_64.exe"'
artifacts:
paths:
- dist/
# --- JOB: Release (Sintaxe Blindada) ---
release-creation:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG =~ /^v/
needs: ["build-linux", "build-windows"]
before_script:
- "apk add --no-cache gnupg curl bash"
script:
- "cd dist"
- "sha256sum seedctl-* > SHA256SUMS"
- 'printf "%s" "$GPG_PRIVATE_KEY" | gpg --batch --import'
- 'echo "$GPG_PASSPHRASE" | gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --armor --detach-sign SHA256SUMS'
# Uploads com caminhos explícitos para evitar erros de expansão de shell
- "curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\" --upload-file SHA256SUMS \"${PACKAGE_REGISTRY_URL}/SHA256SUMS\""
- "curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\" --upload-file SHA256SUMS.asc \"${PACKAGE_REGISTRY_URL}/SHA256SUMS.asc\""
# Usando comandos shell simples para capturar os nomes
- "FILE_APPIMAGE=$(ls seedctl-*-linux-x86_64.AppImage) && curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\" --upload-file \"$FILE_APPIMAGE\" \"${PACKAGE_REGISTRY_URL}/seedctl-linux-x86_64.AppImage\""
- "FILE_EXE=$(ls seedctl-*-windows-x86_64.exe) && curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\" --upload-file \"$FILE_EXE\" \"${PACKAGE_REGISTRY_URL}/seedctl-windows-x86_64.exe\""
- "FILE_RAW=$(ls seedctl-*-linux-x86_64) && curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\" --upload-file \"$FILE_RAW\" \"${PACKAGE_REGISTRY_URL}/seedctl-linux-x86_64\""
release:
name: "Version $CI_COMMIT_TAG"
description: "Automatic release for version $CI_COMMIT_TAG"
tag_name: "$CI_COMMIT_TAG"
assets:
links:
- name: "Linux AppImage"
url: "${PACKAGE_REGISTRY_URL}/seedctl-linux-x86_64.AppImage"
- name: "Windows Executable"
url: "${PACKAGE_REGISTRY_URL}/seedctl-windows-x86_64.exe"
- name: "Linux Binary (Raw)"
url: "${PACKAGE_REGISTRY_URL}/seedctl-linux-x86_64"
- name: "SHA256 Checksums"
url: "${PACKAGE_REGISTRY_URL}/SHA256SUMS"
- name: "GPG Signature"
url: "${PACKAGE_REGISTRY_URL}/SHA256SUMS.asc"