Compare commits

...

12 commits

5 changed files with 205 additions and 3 deletions

183
.drone.yml Normal file
View file

@ -0,0 +1,183 @@
---
kind: pipeline
name: test
steps:
- name: test-code
image: golang
commands:
- go get
- go test
- name: run-code
image: golang
commands:
- go get
- go run .
---
kind: pipeline
name: test-build
steps:
- name: prepare
image: golang
commands:
- go version
- name: build-linux-amd64
image: golang
environment:
GOOS: linux
GOARCH: amd64
commands:
- go get
- go build -o cmw-linux-amd64-${DRONE_COMMIT_SHA:0:8}
depends_on:
- prepare
- name: build-darwin-amd64
image: golang
environment:
GOOS: darwin
GOARCH: amd64
commands:
- go get
- go build -o cmw-darwin-amd64-${DRONE_COMMIT_SHA:0:8}
depends_on:
- prepare
- name: build-windows-amd64
image: golang
environment:
GOOS: windows
GOARCH: amd64
commands:
- go get
- go build -o cmw-windows-amd64-${DRONE_COMMIT_SHA:0:8}.exe
depends_on:
- prepare
- name: build-linux-arm64
image: golang
environment:
GOOS: linux
GOARCH: arm64
commands:
- go get
- go build -o cmw-linux-arm64-${DRONE_COMMIT_SHA:0:8}
depends_on:
- prepare
- name: build-darwin-arm64
image: golang
environment:
GOOS: darwin
GOARCH: arm64
commands:
- go get
- go build -o cmw-darwin-arm64-${DRONE_COMMIT_SHA:0:8}
depends_on:
- prepare
depends_on:
- test
---
kind: pipeline
name: build
steps:
- name: prepare
image: golang
commands:
- mkdir bin/
- name: build-linux-amd64
image: golang
environment:
GOOS: linux
GOARCH: amd64
commands:
- go get
- go build -o bin/cmw-linux-amd64-${DRONE_TAG}
depends_on:
- prepare
- name: build-darwin-amd64
image: golang
environment:
GOOS: darwin
GOARCH: amd64
commands:
- go get
- go build -o bin/cmw-darwin-amd64-${DRONE_TAG}
depends_on:
- prepare
- name: build-windows-amd64
image: golang
environment:
GOOS: windows
GOARCH: amd64
commands:
- go get
- go build -o bin/cmw-windows-amd64-${DRONE_TAG}.exe
depends_on:
- prepare
- name: build-linux-arm64
image: golang
environment:
GOOS: linux
GOARCH: arm64
commands:
- go get
- go build -o bin/cmw-linux-arm64-${DRONE_TAG}
depends_on:
- prepare
- name: build-darwin-arm64
image: golang
environment:
GOOS: darwin
GOARCH: arm64
commands:
- go get
- go build -o bin/cmw-darwin-arm64-${DRONE_TAG}
depends_on:
- prepare
- name: generate-checksum
image: golang
commands:
- cd bin
- md5sum * > ../md5sums.txt
- sha512sum * > ../sha512sums.txt
- cp ../md5sums.txt .
- cp ../sha512sums.txt .
depends_on:
- build-linux-amd64
- build-darwin-amd64
- build-windows-amd64
- build-linux-arm64
- build-darwin-arm64
- name: gitea_release
image: plugins/gitea-release
settings:
title: Release ${DRONE_TAG}
note: This is the cmw release of version ${DRONE_TAG}
api_key:
from_secret:
gitea_release
base_url: https://scm.project42.io
files: bin/*
depends_on:
- generate-checksum
depends_on:
- test-build
trigger:
event:
- tag

14
Dockerfile Normal file
View file

@ -0,0 +1,14 @@
FROM docker.io/library/golang:alpine as builder
ADD . /cmw
RUN apk add git && \
cd /cmw && \
go get -u . && \
go build -o cmw
FROM docker.io/library/alpine:latest
COPY --from=builder /cmw/cmw /cmw
ENTRYPOINT ["/cmw"]

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module go-cmw
go 1.20

View file

@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
@ -15,7 +14,7 @@ import (
)
// VERSION The version release
const VERSION = "0.1.4"
const VERSION = "0.1.5"
// AUTHOR The author name
const AUTHOR = "Elia el Lazkani"
@ -72,7 +71,7 @@ func (w weather) get(req *http.Request, download bool) {
// `weather` method to print the weather
func (w weather) print(resp *http.Response) {
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal("Error reading body. ", err)
}

3
renovate.json Normal file
View file

@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}