mirror of
https://github.com/denisidoro/navi.git
synced 2026-01-23 02:14:19 +00:00
Update the Continuous Deployment pipeline with a minimal amount of dependencies (#971)
* Merged dotfiles/scripts into navi/scripts Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Fixes the permission denied issue Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Update log functions Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Test new workflow Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Update cd.yml * Update release script Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Fix attempt Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Update the set-ouput method Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Added debugging log::info Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fixe issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Removed debugging log::info Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Adds more comments on what the expressions does Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Add once again the use of UPX for the linux releases Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Tries to fix issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> * Comment UPX until I found how it was used and implemented it correctly Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> --------- Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com>
This commit is contained in:
parent
9a6fae871a
commit
138b7e0b00
2 changed files with 166 additions and 17 deletions
54
.github/workflows/cd.yml
vendored
54
.github/workflows/cd.yml
vendored
|
|
@ -4,6 +4,7 @@ on:
|
|||
push:
|
||||
tags:
|
||||
- "*"
|
||||
release:
|
||||
|
||||
jobs:
|
||||
binary:
|
||||
|
|
@ -30,23 +31,42 @@ jobs:
|
|||
- os: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@v1.3.4
|
||||
with:
|
||||
rust-version: stable
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install target
|
||||
id: installtarget
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
- name: Build
|
||||
id: build
|
||||
run: scripts/dot rust release ${{ matrix.target }}
|
||||
### We're checking out the repository at the triggered ref
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if release exists
|
||||
id: check_release
|
||||
run: |
|
||||
if gh release view ${{ steps.get_version.outputs.VERSION }} > /dev/null 2>&1; then
|
||||
echo "RELEASE_EXISTS=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "RELEASE_EXISTS=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release
|
||||
continue-on-error: true
|
||||
if: steps.check_release.outputs.RELEASE_EXISTS == 'false'
|
||||
run: |
|
||||
gh release create ${{ steps.get_version.outputs.VERSION }} \
|
||||
--title "Release ${{ steps.get_version.outputs.VERSION }}" \
|
||||
--notes "Release notes for ${{ steps.get_version.outputs.VERSION }}" \
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
run: scripts/release ${{ matrix.target }}
|
||||
|
||||
- name: Upload binaries to release
|
||||
uses: svenstaro/upload-release-action@v1-release
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: target/tar/navi.${{ steps.build.outputs.EXTENSION }}
|
||||
tag: ${{ github.ref }}
|
||||
asset_name: navi-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.${{ steps.build.outputs.EXTENSION }}
|
||||
run: |
|
||||
cd ./target/${{ matrix.target }}/release/
|
||||
cp navi.${{ steps.build.outputs.EXTENSION }} navi-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.${{ steps.build.outputs.EXTENSION }}
|
||||
gh release upload ${{ steps.get_version.outputs.VERSION }} navi-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.${{ steps.build.outputs.EXTENSION }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
|
|
|||
129
scripts/release
Executable file
129
scripts/release
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
### Logging functions
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
log::info() {
|
||||
### Will print `[INFO]` in black foreground colour and magenta background colour
|
||||
### then will print the given text in a magenta foreground colour and default background colour.
|
||||
printf "\033[35m\033[7m[INFO]\033[27;39m \033[35m$*\033[39m\n"
|
||||
}
|
||||
|
||||
log::error() {
|
||||
### Will print `[ERROR]` in black foreground colour and red background colour
|
||||
### then will print the given text in a red foreground colour and default background colour.
|
||||
printf "\033[31m\033[7m[ERROR]\033[27;39m \033[31m$*\033[39m\n"
|
||||
}
|
||||
|
||||
log::warn() {
|
||||
### Will print `[WARNING]` in black foreground colour and yellow background colour
|
||||
### then will print the given text in a yellow foreground colour and default background colour.
|
||||
printf "\033[33m\033[7m[WARNING]\033[27;39m \033[33m$*\033[39m\n"
|
||||
}
|
||||
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
### Utils functions
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
### Permits us to know if the current target environment
|
||||
### is a windows platform or not.
|
||||
is_windows() {
|
||||
local -r target="$1"
|
||||
echo "$target" | grep -q "windows"
|
||||
}
|
||||
|
||||
### NOTE: This function is currently not in use but kept as
|
||||
### a backup function in case something breaks
|
||||
###
|
||||
### Returns the target environment, with a fix for the x86_64 target.
|
||||
get_env_target() {
|
||||
eval "$(rustc --print cfg | grep target)"
|
||||
local -rr raw="${target_arch:-}-${target_vendor:-}-${target_os:-}-${target_env:-}"
|
||||
|
||||
if echo "$raw" | grep -q "x86_64-apple-macos"; then
|
||||
echo "x86_64-apple-darwin"
|
||||
else
|
||||
echo "$raw"
|
||||
fi
|
||||
}
|
||||
|
||||
### NOTE: This function is currently not in use but kept as
|
||||
### a backup function in case something breaks
|
||||
###
|
||||
### Logs the given arguments then execute it
|
||||
_tap() {
|
||||
log::info "$@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
### NOTE: This function is currently not in use but kept as
|
||||
### a backup function in case something breaks
|
||||
###
|
||||
### Lists the content of a path, given as parameter.
|
||||
_ls() {
|
||||
log::info "contents from $*:"
|
||||
ls -la "$@" || true
|
||||
}
|
||||
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
### Release-Related functions
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
release() {
|
||||
local -r env_target="$1"
|
||||
log::info "env target: $env_target"
|
||||
|
||||
local -r cross_target="${1:-"$env_target"}"
|
||||
log::info "desired target: $cross_target"
|
||||
|
||||
TAR_DIR="$(pwd)/target/tar"
|
||||
|
||||
### We clean up the target folder, just in case
|
||||
rm -rf "$(pwd)/target" 2> /dev/null || true
|
||||
|
||||
### We add the target for rustup in case cross doesn't find it.
|
||||
### Since the default behaviour of cross is to compile from
|
||||
### a rustup target if it doesn't find one for itself.
|
||||
rustup target add $env_target
|
||||
cargo install cross
|
||||
|
||||
### We're building the release via cross for the target environment
|
||||
cross build --release --target "$env_target"
|
||||
|
||||
cd target/"$env_target"/release/
|
||||
|
||||
if is_windows "$env_target"; then
|
||||
### If our target is windows, we can simply zip our executable
|
||||
### since having tar is not the norm and neither the default
|
||||
zip -r "navi.zip" "navi.exe"
|
||||
|
||||
### We export a CI/CD variable to be used later in the pipeline
|
||||
echo "EXTENSION=zip" >> $GITHUB_OUTPUT
|
||||
else
|
||||
|
||||
### @alexis-opolka - I'm currently disabling the usage of UPX since I cannot find how
|
||||
### it was used before the merge of the code from the @denisidoro/dotfiles repository.
|
||||
###
|
||||
#if upx --best --lzma "navi"; then
|
||||
# log::info "upx succeeded"
|
||||
#else
|
||||
# log::info "upx failed"
|
||||
#fi
|
||||
|
||||
|
||||
### For all other targets, they have tar as the norm
|
||||
### or have it installed by default.
|
||||
tar -czf "navi.tar.gz" "navi"
|
||||
|
||||
### We export a CI/CD variable to be used later in the pipeline
|
||||
echo "EXTENSION=tar.gz" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
### Main script
|
||||
### --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
release "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue