update github workflows (#70)

Maintenance.
This commit is contained in:
Pierre Carrier
2023-11-13 19:15:26 +01:00
committed by GitHub
parent 642039d436
commit c52e483b8a
4 changed files with 24 additions and 18 deletions

View File

@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go-version: ['1.17', '1.18', '1.19'] go-version: ['1.19', '1.20', '1.21']
steps: steps:
- name: Install Go ${{ matrix.go-version }} - name: Install Go ${{ matrix.go-version }}
uses: actions/setup-go@v3 uses: actions/setup-go@v4
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: creachadair/go-presubmit-action@v1 - uses: creachadair/go-presubmit-action@v2
with: with:
staticcheck-version: "2022.1.3" staticcheck-version: "2023.1.6"

View File

@ -17,31 +17,29 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v4
with: with:
go-version: 1.17 go-version: 1.21
- name: Run GoReleaser release (SKIP publish) - name: Run GoReleaser release (SKIP publish)
uses: goreleaser/goreleaser-action@v3 uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/') != true if: startsWith(github.ref, 'refs/tags/') != true
with: with:
distribution: goreleaser distribution: goreleaser
version: latest version: latest
args: release --rm-dist --skip-publish args: release --clean --skip=publish --snapshot
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser release - name: Run GoReleaser release
uses: goreleaser/goreleaser-action@v3 uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
distribution: goreleaser distribution: goreleaser
version: latest version: latest
args: release --rm-dist args: release --clean
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -113,6 +113,10 @@ func addCode(accountName string) {
// Check for encryption and ask for password if necessary // Check for encryption and ask for password if necessary
_, isEncrypted, err := gauth.ReadConfigFile(cfgPath) _, isEncrypted, err := gauth.ReadConfigFile(cfgPath)
if err != nil {
log.Fatalf("Reading config: %v", err)
}
password, err := []byte(nil), nil password, err := []byte(nil), nil
if isEncrypted { if isEncrypted {
@ -169,13 +173,17 @@ func removeCode(accountName string) {
// Check for encryption and ask for password if necessary // Check for encryption and ask for password if necessary
_, isEncrypted, err := gauth.ReadConfigFile(cfgPath) _, isEncrypted, err := gauth.ReadConfigFile(cfgPath)
if err != nil {
log.Fatalf("Reading config: %v", err)
}
password, err := []byte(nil), nil password, err := []byte(nil), nil
if isEncrypted { if isEncrypted {
password, err = getPassword() password, err = getPassword()
if err != nil { if err != nil {
log.Fatalf("reading passphrase: %v", err) log.Fatalf("Reading passphrase: %v", err)
} }
} }

View File

@ -12,7 +12,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"hash" "hash"
"io/ioutil" "os"
"strings" "strings"
"time" "time"
@ -78,7 +78,7 @@ func CodesAtTimeStep(u *otpauth.URL, timeStep uint64) (prev, curr, next string,
// ReadConfigFile reads the config file at path and returns its contents and // ReadConfigFile reads the config file at path and returns its contents and
// whether it is encrypted or not // whether it is encrypted or not
func ReadConfigFile(path string) ([]byte, bool, error) { func ReadConfigFile(path string) ([]byte, bool, error) {
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
} }
@ -184,7 +184,7 @@ func WriteConfigFile(path string, passwd []byte, newConfig []byte) error {
newConfig = append(saltedPrefix, newConfig...) newConfig = append(saltedPrefix, newConfig...)
} }
err = ioutil.WriteFile(path, newConfig, 0) err = os.WriteFile(path, newConfig, 0)
if err != nil { if err != nil {
return fmt.Errorf("writing config: %v", err) return fmt.Errorf("writing config: %v", err)