Skip to content

Commit 9364e59

Browse files
authored
CI/CD and Download Compiled Version (#1)
* ci * 1.20 * use go.mod * copy paste install and examples * more help
1 parent 6a2ff7a commit 9364e59

File tree

6 files changed

+266
-12
lines changed

6 files changed

+266
-12
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "CI"
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
name: CI/CD Test
11+
# https://github.com/actions/virtual-environments/
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: 🛎️ Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: 🔧 Setup go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version-file: 'go.mod'
22+
23+
# Test
24+
- name: 🌡️ Test
25+
run: go run main.go -h

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build:
10+
name: Build
11+
# https://github.com/actions/virtual-environments/
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: 🛎️ Checkout
16+
uses: actions/checkout@v3
17+
18+
# https://github.com/marketplace/actions/setup-go-environment
19+
- name: 🔧 Setup go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version-file: 'go.mod'
23+
24+
- name: 🍳 Build
25+
run: bash build.sh
26+
27+
# Test binary
28+
- name: 🌡️ Test
29+
run: chmod +x go-andotp-linux-x86_64 && ./go-andotp-linux-x86_64 -h
30+
31+
# Upload binaries
32+
# https://github.com/marketplace/actions/upload-a-build-artifact
33+
- name: 📤 Upload
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: go-andotp
37+
path: go-andotp*
38+
retention-days: 1
39+
40+
test-linux:
41+
name: Test Linux
42+
needs: build
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: 🛎️ Checkout
46+
uses: actions/checkout@v3
47+
# Download binaries
48+
# https://github.com/marketplace/actions/download-a-build-artifact
49+
- name: 📥 Download
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: go-andotp
53+
# Test binary
54+
- name: 🌡️ Test
55+
run: chmod +x go-andotp-linux-x86_64 && ./go-andotp-linux-x86_64 -h
56+
57+
test-macos:
58+
name: Test macOS
59+
needs: build
60+
runs-on: macos-latest
61+
steps:
62+
- name: 🛎️ Checkout
63+
uses: actions/checkout@v3
64+
- name: 📥 Download
65+
uses: actions/download-artifact@v3
66+
with:
67+
name: go-andotp
68+
# Test binary
69+
- name: 🌡️ Test
70+
run: chmod +x go-andotp-macos-x86_64 && ./go-andotp-macos-x86_64 -h
71+
72+
test-windows:
73+
name: Test Windows
74+
needs: build
75+
runs-on: windows-latest
76+
steps:
77+
- name: 🛎️ Checkout
78+
uses: actions/checkout@v3
79+
- name: 📥 Download
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: go-andotp
83+
# Test binary
84+
- name: 🌡️ Test
85+
run: .\go-andotp-windows-x86_64.exe -h
86+
87+
release:
88+
name: Release
89+
needs: [test-linux, test-macos, test-windows]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: 🛎️ Checkout
93+
uses: actions/checkout@v3
94+
- name: 📥 Download
95+
uses: actions/download-artifact@v3
96+
with:
97+
name: go-andotp
98+
# Release, upload files
99+
# https://github.com/marketplace/actions/gh-release
100+
- name: ✨ Release
101+
uses: softprops/action-gh-release@v1
102+
with:
103+
files: |
104+
go-andotp-linux-x86_64
105+
go-andotp-linux-arm64
106+
go-andotp-macos-x86_64
107+
go-andotp-macos-arm64
108+
go-andotp-windows-x86_64.exe
109+
go-andotp-windows-arm64.exe

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
go-andotp*
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Dependency directories (remove the comment below to include it)
17+
# vendor/
18+
19+
# Go workspace file
20+
go.work

README.md

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,72 @@
22
CLI program to encrypt/decrypt [andOTP](https://github.com/andOTP/andOTP) files.
33

44
## Installation
5-
```sh
6-
$ go get github.com/grijul/go-andotp
5+
6+
<details>
7+
<summary><b>Linux</b></summary>
8+
9+
Download:
10+
* [x86_64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-linux-x86_64) Intel or AMD 64-Bit CPU
11+
```shell
12+
curl -L "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-linux-x86_64" \
13+
-o "go-andotp" && \
14+
chmod +x "go-andotp"
15+
```
16+
* [arm64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-linux-arm64) Arm-based 64-Bit CPU (i.e. in Raspberry Pi)
17+
```shell
18+
curl -L "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-linux-arm64" \
19+
-o "go-andotp" && \
20+
chmod +x "go-andotp"
21+
```
22+
23+
To determine your OS version, run `getconf LONG_BIT` or `uname -m` at the command line.
24+
</details>
25+
26+
<details>
27+
<summary><b>macOS</b></summary>
28+
29+
Download:
30+
* [x86_64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-macos-x86_64) Intel 64-bit
31+
```shell
32+
curl -L "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-macos-x86_64" \
33+
-o "go-andotp" && \
34+
chmod +x "go-andotp"
35+
```
36+
* [arm64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-macos-arm64) Apple silicon 64-bit
37+
```shell
38+
curl -L "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-macos-arm64" \
39+
-o "go-andotp" && \
40+
chmod +x "go-andotp"
41+
```
42+
43+
To determine your OS version, run `uname -m` at the command line.
44+
</details>
45+
46+
<details>
47+
<summary><b>Windows</b></summary>
48+
49+
Download:
50+
* [x86_64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-windows-x86_64.exe) Intel or AMD 64-Bit CPU
51+
```powershell
52+
Invoke-WebRequest -Uri "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-windows-x86_64.exe" -OutFile "go-andotp.exe"
53+
```
54+
* [arm64](https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-windows-arm64.exe) Arm-based 64-Bit CPU
55+
```powershell
56+
Invoke-WebRequest -Uri "https://github.com/RijulGulati/go-andotp/releases/latest/download/go-andotp-windows-arm64.exe" -OutFile "go-andotp.exe"
57+
```
58+
To determine your OS version, run `echo %PROCESSOR_ARCHITECTURE%` at the command line.
59+
</details>
60+
61+
<details>
62+
<summary><b>Go</b></summary>
63+
64+
```shell
65+
go install github.com/grijul/go-andotp
766
```
67+
</details>
868

969
## Usage
10-
```sh
70+
```text
1171
Usage: go-andotp -i <INPUT_FILE> {-e|-d} [-o <OUT_FILE>] [-p PASSWORD]
1272
1373
-d Decrypt file
@@ -22,20 +82,20 @@ Usage: go-andotp -i <INPUT_FILE> {-e|-d} [-o <OUT_FILE>] [-p PASSWORD]
2282

2383
## Examples
2484
- Encrypt JSON file (Password is asked after hitting ```Enter```. Password is not echoed)
25-
```sh
26-
$ go-andotp -e -i file.json -o file.json.aes
85+
```shell
86+
go-andotp -e -i file.json -o file.json.aes
2787
```
2888
- Encrypt JSON file (Password is entered through CLI)
29-
```sh
30-
$ go-andotp -e -i file.json -o file.json.aes -p testpass
89+
```shell
90+
go-andotp -e -i file.json -o file.json.aes -p testpass
3191
```
3292
- Decrypt JSON file
33-
```sh
34-
$ go-andotp -d -i file.aes.json -o file.json
93+
```shell
94+
go-andotp -d -i file.aes.json -o file.json
3595
```
3696
- Decrypt JSON file and print json to console
37-
```sh
38-
$ go-andotp -d -i file.aes.json
97+
```shell
98+
go-andotp -d -i file.aes.json
3999
```
40100

41101
## Using go-andotp as library
@@ -52,5 +112,25 @@ func main() {
52112
}
53113
```
54114

115+
## Build
116+
Compile `go-andotp` on your computer:
117+
118+
```shell
119+
go build -o go-andotp main.go
120+
```
121+
122+
To compile `go-andotp` for another platform please set the `GOARCH` and `GOOS` environmental variables.
123+
Example:
124+
```shell
125+
GOOS=windows GOARCH=amd64 go build -o go-andotp.exe main.go
126+
```
127+
128+
To compile `go-andotp` for Windows, macOS and Linux you can use the script `build.sh`:
129+
```shell
130+
bash build.sh
131+
```
132+
133+
More help: <https://go.dev/doc/install/source#environment>
134+
55135
# License
56136
[MIT](https://github.com/grijul/go-andotp/blob/main/LICENSE)

build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
go version || exit 9
4+
5+
# Linux
6+
echo "Linux" && \
7+
GOOS=linux GOARCH=amd64 go build -o go-andotp-linux-x86_64 main.go && \
8+
GOOS=linux GOARCH=arm64 go build -o go-andotp-linux-arm64 main.go && \
9+
10+
# macOS
11+
echo "macOS" && \
12+
GOOS=darwin GOARCH=amd64 go build -o go-andotp-macos-x86_64 main.go && \
13+
GOOS=darwin GOARCH=arm64 go build -o go-andotp-macos-arm64 main.go && \
14+
15+
# Windows
16+
echo "Windows" && \
17+
GOOS=windows GOARCH=amd64 go build -o go-andotp-windows-x86_64.exe main.go && \
18+
GOOS=windows GOARCH=arm64 go build -o go-andotp-windows-arm64.exe main.go && \
19+
20+
echo "✅ DONE"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/grijul/go-andotp
22

3-
go 1.16
3+
go 1.20
44

55
require (
66
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf

0 commit comments

Comments
 (0)