make complete publish script #2
All checks were successful
/ publish_password (push) Successful in 6m40s
All checks were successful
/ publish_password (push) Successful in 6m40s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
3e6f106e81
commit
f9ce04a257
4 changed files with 47 additions and 25 deletions
|
|
@ -4,15 +4,24 @@ on:
|
||||||
push:
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish_password:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- run: echo All good!
|
- name: "publish_password: Download packages"
|
||||||
- run: apt-get update && apt-get install -y make
|
run: apt-get update && apt-get install -y make
|
||||||
- uses: actions/checkout@v4
|
- name: "publish_password: Checkout repo"
|
||||||
- uses: actions/setup-go@v5
|
uses: actions/checkout@v4
|
||||||
|
- name: "publish_password: Setup golang"
|
||||||
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.21"
|
go-version: "1.21"
|
||||||
- run: ls -la
|
- name: "publish_password: build binary"
|
||||||
- run: make build_password
|
run: make build_password
|
||||||
- run: make publish_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
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, closed]
|
types: [opened, closed]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
validate_password:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- run: echo All good!
|
- run: echo All good!
|
||||||
|
|
|
||||||
20
Makefile
20
Makefile
|
|
@ -1,14 +1,10 @@
|
||||||
ARCH := amd64 arm64
|
ARCH := amd64 arm64
|
||||||
OS := linux windows darwin
|
OS := linux windows darwin
|
||||||
NAME := password
|
NAME := password
|
||||||
VERSION := $(shell git describe)
|
|
||||||
BUILD := $(shell git rev-parse HEAD)
|
|
||||||
|
|
||||||
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
|
.PHONY: all build_password
|
||||||
|
|
||||||
.PHONY: all build
|
all: build_password
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build_password:
|
build_password:
|
||||||
$(foreach GOOS, ${OS},\
|
$(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) \
|
$(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:
|
clean:
|
||||||
rm -rf bin
|
rm -rf bin
|
||||||
|
|
||||||
|
|
|
||||||
23
scripts/publish_packages.sh
Normal file
23
scripts/publish_packages.sh
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue