Skip to content

Commit

Permalink
chore: first ready script, tested
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-segning committed Aug 13, 2024
1 parent 9538a91 commit 2c23933
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- '**'
tags-ignore:
tags:
- 'v*'
paths:
- '.github/workflows/build.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/helm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- '*' # Matches all branches
tags:
- 'v*'
paths:
- 'helm/Chart.yaml'
- '.github/workflows/helm-publish.yml'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- '**'
tags-ignore:
tags:
- 'v*'
paths:
- '.github/workflows/release.yml'
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: github.ref == 'refs/head/main'
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -179,7 +179,7 @@ jobs:

- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/head/main'
if: startsWith(github.ref, 'refs/tags/v')
with:
files: '**'
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*/target

.idea
*.pem
*.pem
charts
6 changes: 6 additions & 0 deletions helm/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.22.0
digest: sha256:9c1e47083e72c851d44887a321bb2cc2873115365d5edd0e7b9682727f3e0a7d
generated: "2024-08-13T20:39:21.139286608+01:00"
10 changes: 9 additions & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.1
version: 0.1.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.1"

dependencies:
- name: common
version: '*'
repository: https://charts.bitnami.com/bitnami
tags:
- common
- bitnami-common
2 changes: 1 addition & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ env:
- name: ROOT_CA_PATH
value: "/usr/share/wazuh-cert-oauth2/certs/root-ca.pem"
- name: ROOT_CA_KEY_PATH
value: "/usr/share/wazuh-cert-oauth2/certs/root-ca.pem"
value: "/usr/share/wazuh-cert-oauth2/certs/root-ca-key.pem"

nodeSelector: {}

Expand Down
33 changes: 12 additions & 21 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if (-not $WOPS_VERSION) {
}

# Set the app configuration folder and bin directory
$ConfigDir = Join-Path -Path $env:APPDATA -ChildPath "wazuh-cert-oauth2-client"
$BinDir = Join-Path -Path $env:USERPROFILE -ChildPath "AppData\Local\Microsoft\WindowsApps"

# Determine the architecture
Expand All @@ -26,39 +25,31 @@ switch ($Arch) {
default { ErrorExit "Unsupported architecture: $Arch" }
}

# URL for downloading the zip file
$BaseUrl = "https://github.com/ADORSYS-GIS/wazuh-cert-oauth2/releases/download/v$WOPS_VERSION"
$ZipFile = "wazuh-cert-oauth2-client-$Arch-windows.zip"
$Url = "$BaseUrl/$ZipFile"
# Construct the full binary name
$BinName = "wazuh-cert-oauth2-client-$Arch-pc-windows-msvc"

# Download the zip file
$TempZipPath = Join-Path -Path $env:TEMP -ChildPath $ZipFile
Write-Host "Downloading $ZipFile from $Url..."
try {
Invoke-WebRequest -Uri $Url -OutFile $TempZipPath -ErrorAction Stop
} catch {
ErrorExit "Failed to download $ZipFile"
}
# URL for downloading the binary
$BaseUrl = "https://github.com/ADORSYS-GIS/wazuh-cert-oauth2/releases/download/v$WOPS_VERSION"
$Url = "$BaseUrl/$BinName"

# Unzip the file
$TempExtractDir = Join-Path -Path $env:TEMP -ChildPath "wazuh-cert-oauth2-client"
Write-Host "Unzipping $ZipFile..."
# Download the binary file
$TempBinPath = Join-Path -Path $env:TEMP -ChildPath $BinName
Write-Host "Downloading $BinName from $Url..."
try {
Expand-Archive -Path $TempZipPath -DestinationPath $TempExtractDir -Force
Invoke-WebRequest -Uri $Url -OutFile $TempBinPath -ErrorAction Stop
} catch {
ErrorExit "Failed to unzip $ZipFile"
ErrorExit "Failed to download $BinName"
}

# Move the binary to the BinDir
Write-Host "Installing binary to $BinDir..."
try {
Move-Item -Path (Join-Path -Path $TempExtractDir -ChildPath "wazuh-cert-oauth2-client.exe") -Destination (Join-Path -Path $BinDir -ChildPath "wazuh-cert-oauth2-client.exe") -Force
Move-Item -Path $TempBinPath -Destination (Join-Path -Path $BinDir -ChildPath "wazuh-cert-oauth2-client.exe") -Force
} catch {
ErrorExit "Failed to move binary to $BinDir"
}

# Cleanup
Remove-Item -Path $TempZipPath -Force
Remove-Item -Path $TempExtractDir -Recurse -Force
Remove-Item -Path $TempBinPath -Force

Write-Host "Installation complete! You can now use 'wazuh-cert-oauth2-client' from your terminal."
28 changes: 12 additions & 16 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ WOPS_VERSION=${WOPS_VERSION:-"latest"}
# Determine the OS and set paths accordingly
case "$(uname)" in
"Linux")
CONFIG_DIR="$HOME/.config/wazuh-cert-oauth2-client"
OS="unknown-linux-gnu"
BIN_DIR="$HOME/.local/bin"
OS="linux"
;;
"Darwin")
CONFIG_DIR="$HOME/Library/Application Support/wazuh-cert-oauth2-client"
OS="apple-darwin"
BIN_DIR="/usr/local/bin"
OS="macos"
;;
*)
error_exit "Unsupported operating system: $(uname)"
Expand All @@ -42,26 +40,24 @@ case "$ARCH" in
;;
esac

# URL for downloading the zip file
BASE_URL="https://github.com/ADORSYS-GIS/wazuh-cert-oauth2/releases/download/v$WOPS_VERSION"
ZIP_FILE="wazuh-cert-oauth2-client-${ARCH}-${OS}.zip"
URL="$BASE_URL/$ZIP_FILE"
# Construct the full binary name
BIN_NAME="wazuh-cert-oauth2-client-${ARCH}-${OS}"

# Download the zip file
echo "Downloading $ZIP_FILE from $URL..."
curl -L -o "/tmp/$ZIP_FILE" "$URL" || error_exit "Failed to download $ZIP_FILE"
# URL for downloading the binary
BASE_URL="https://github.com/ADORSYS-GIS/wazuh-cert-oauth2/releases/download/v$WOPS_VERSION"
URL="$BASE_URL/$BIN_NAME"

# Unzip the file
echo "Unzipping $ZIP_FILE..."
unzip -o "/tmp/$ZIP_FILE" -d "/tmp/wazuh-cert-oauth2-client" || error_exit "Failed to unzip $ZIP_FILE"
# Download the binary file
echo "Downloading $BIN_NAME from $URL..."
curl -L -o "/tmp/$BIN_NAME" "$URL" || error_exit "Failed to download $BIN_NAME"

# Move the binary to the BIN_DIR
echo "Installing binary to $BIN_DIR..."
mkdir -p "$BIN_DIR"
mv "/tmp/wazuh-cert-oauth2-client/wazuh-cert-oauth2-client" "$BIN_DIR/" || error_exit "Failed to move binary to $BIN_DIR"
mv "/tmp/$BIN_NAME" "$BIN_DIR/wazuh-cert-oauth2-client" || error_exit "Failed to move binary to $BIN_DIR"
chmod +x "$BIN_DIR/wazuh-cert-oauth2-client" || error_exit "Failed to set executable permissions on the binary"

# Cleanup
rm -rf "/tmp/$ZIP_FILE" "/tmp/wazuh-cert-oauth2-client"
rm -rf "/tmp/$BIN_NAME"

echo "Installation complete! You can now use 'wazuh-cert-oauth2-client' from your terminal."
4 changes: 2 additions & 2 deletions wazuh-cert-oauth2-client/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wazuh-cert-oauth2-model/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wazuh-cert-oauth2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c23933

Please sign in to comment.