Merge pull request 'update Makefile #2' (#6) from #2 into main

Reviewed-on: #6
This commit is contained in:
nicolas.boufideline 2025-08-12 20:53:43 +00:00
commit 113f8b8431
5 changed files with 72 additions and 28 deletions

View file

@ -1,13 +0,0 @@
on: [push]
jobs:
release:
runs-on: docker
steps:
- run: echo All good!
- run: apt-get update && apt-get install -y make
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- run: ls -la
- run: make build_password

View file

@ -0,0 +1,26 @@
on:
pull_request:
types: [closed]
jobs:
publish_password:
runs-on: docker
steps:
- name: "publish_password: Download packages"
run: apt-get update && apt-get install -y make
- name: "publish_password: Checkout repo"
uses: actions/checkout@v4
- name: "publish_password: Setup golang"
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: "publish_password: build binary"
run: make build_password
- name: "publish_password: publish binary"
run: echo "${PASSWORD}" && bash ./scripts/publish_packages.sh "./bin" "password"
env:
LOGIN: ${{ forge.ACTOR }}
PASSWORD: ${{ secrets.PACKAGE }}
SERVER_URL: ${{ forge.SERVER_URL }}
OWNER: ${{ forge.REPOSITORY_OWNER }}
VER: latest

View file

@ -0,0 +1,18 @@
on:
pull_request:
types: [opened, synchronize, closed]
jobs:
validate_password:
runs-on: docker
steps:
- name: "validate_password: Download packages"
run: apt-get update && apt-get install -y make
- name: "validate_password: Checkout repo"
uses: actions/checkout@v4
- name: "validate_password: Setup golang"
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: "validate_password: build binary"
run: make build_password

View file

@ -1,14 +1,10 @@
ARCH := amd64 arm64
OS := linux windows darwin
NAME := password
VERSION := $(shell git describe)
BUILD := $(shell git rev-parse HEAD)
ARCH := amd64 arm64
OS := linux windows darwin
NAME := password
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
.PHONY: all build_password
.PHONY: all build
all: build
all: build_password
build_password:
$(foreach GOOS, ${OS},\
@ -16,12 +12,6 @@ build_password:
$(shell CGO_ENABLED=0 go build -v -o bin/${NAME} ./golang/cmd/passwordhash;cd bin/;[ "${GOOS}" = "windows" ] && mv ${NAME} ${NAME}.exe;tar czf ${NAME}_${GOOS}_${GOARCH}.tar.gz *;rm -f ${NAME} ${NAME}.exe) \
))
publish_password:
$(foreach GOOS, ${OS},\
$(foreach GOARCH, ${ARCH}, \
$(curl --silent --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${NAME}_${GOOS}_${GOARCH}.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${NAME}/${VER}/${NAME}_${GOOS}_${GOARCH}.tar.gz") \
))
clean:
rm -rf bin

View file

@ -0,0 +1,23 @@
#!/bin/bash
echo "Publish generique package"
PATH_DIR="${1}"
NAME="${2}"
USER="${LOGIN}"
TOKEN="${PASSWORD}"
echo "user -> ${USER}"
echo "token -> ${TOKEN}"
echo "server -> ${SERVER_URL}"
echo "owner -> ${OWNER}"
ls "${PATH_DIR}" | while read tmp
do
curl --silent --user "${USER}:${TOKEN}" -X DELETE "${SERVER_URL}/api/packages/${OWNER}/generic/${NAME}/${VER}/${tmp}" && \
echo delete ok || \
echo delete not necessarie
curl --silent --user "${USER}:${TOKEN}" --upload-file "${PATH_DIR}/${tmp}" "${SERVER_URL}/api/packages/${OWNER}/generic/${NAME}/${VER}/${tmp}" && \
echo upload ok || \
echo upload fail
done