-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ipfs/ipdx/june
Implement improvements requested by the IP Shipyard team
- Loading branch information
Showing
10 changed files
with
292 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
actions/embed/.env.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
actions/embed/.env.template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/env bash | ||
|
||
github_token="$GITHUB_TOKEN" | ||
if [[ -z "$github_token" ]]; then | ||
echo "Please provide a GitHub token. You can create one at:" | ||
echo " https://github.com/settings/tokens/new?scopes=repo,read:user,user:email,write:packages" | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "GitHub token: " | ||
read -s github_token | ||
fi | ||
|
||
github_user_name="$GITHUB_USER_NAME" | ||
if [[ -z "$github_user_name" ]]; then | ||
github_user_name="$(git config --global user.name)" | ||
fi | ||
if [[ -z "$github_user_name" ]]; then | ||
echo "Please provide a GitHub user name. You can also configure it with:" | ||
echo " git config --global user.name \"Your Name\"" | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "GitHub user name: " | ||
read github_user_name | ||
fi | ||
|
||
github_user_email="$GITHUB_USER_EMAIL" | ||
if [[ -z "$github_user_email" ]]; then | ||
github_user_email="$(git config --global user.email)" | ||
fi | ||
if [[ -z "$github_user_email" ]]; then | ||
echo "Please provide a GitHub user email. You can also configure it with:" | ||
echo " git config --global user.email \"Your Email\"" | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "GitHub user email: " | ||
read github_user_email | ||
fi | ||
|
||
if [[ -z "$NO_GPG" ]]; then | ||
gpg_id="$GPG_ID" | ||
if [[ -z "$gpg_id" ]]; then | ||
gpg_id="$(git config --global user.signingkey)" | ||
fi | ||
if [[ -z "$gpg_id" ]]; then | ||
echo "Please provide a GPG ID. You can also configure it by following:" | ||
echo " https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key" | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "GPG ID: " | ||
read gpg_id | ||
fi | ||
if [[ -n "$gpg_id" ]]; then | ||
gpg_passphrase="$GPG_PASSPHRASE" | ||
if [[ -z "$gpg_passphrase" ]]; then | ||
echo "Please provide a GPG passphrase for the key $gpg_id." | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "GPG passphrase: " | ||
read -s gpg_passphrase | ||
fi | ||
if [[ -n "$gpg_passphrase" ]]; then | ||
gpg_key="$GPG_KEY" | ||
if [[ -z "$gpg_key" ]]; then | ||
gpg_key="$(gpg --armor --pinentry-mode=loopback --passphrase "$gpg_passphrase" --export-secret-key "$gpg_id" -w0 | base64 -w0)" | ||
fi | ||
fi | ||
fi | ||
fi | ||
|
||
if [[ -z "$NO_MATRIX" ]]; then | ||
matrix_url="$MATRIX_URL" | ||
if [[ -z "$matrix_url" ]]; then | ||
echo "Please provide a Matrix URL. For example: https://matrix-client.matrix.org/" | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "Matrix URL: " | ||
read matrix_url | ||
fi | ||
matrix_user="$MATRIX_USER" | ||
if [[ -z "$matrix_user" ]]; then | ||
echo "Please provide a Matrix username." | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "Matrix username: " | ||
read matrix_user | ||
fi | ||
|
||
matrix_password="$MATRIX_PASSWORD" | ||
if [[ -z "$matrix_password" ]]; then | ||
echo "Please provide a Matrix password." | ||
echo "If you don't want the value to be stored in a file, leave it empty and you will be prompted for it later." | ||
echo "Matrix password: " | ||
read -s matrix_password | ||
fi | ||
fi | ||
|
||
export GITHUB_TOKEN="$github_token" | ||
export GITHUB_USER_NAME="$github_user_name" | ||
export GITHUB_USER_EMAIL="$github_user_email" | ||
|
||
export NO_GPG="$NO_GPG" | ||
export GPG_ID="$gpg_id" | ||
export GPG_PASSPHRASE="$gpg_passphrase" | ||
export GPG_KEY="$gpg_key" | ||
|
||
export NO_MATRIX="$NO_MATRIX" | ||
export MATRIX_URL="$matrix_url" | ||
export MATRIX_USER="$matrix_user" | ||
export MATRIX_PASSWORD="$matrix_password" | ||
|
||
|
||
# cat $ENV_TEMPLATE or fall back to .env.template | ||
cat "${ENV_TEMPLATE:-.env.template}" | envsubst > .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GITHUB_TOKEN=$GITHUB_TOKEN | ||
GITHUB_USER_NAME=$GITHUB_USER_NAME | ||
GITHUB_USER_EMAIL=$GITHUB_USER_EMAIL | ||
|
||
NO_GPG=$NO_GPG | ||
GPG_ID=$GPG_ID | ||
GPG_KEY=$GPG_KEY | ||
GPG_PASSPHRASE=$GPG_PASSPHRASE | ||
|
||
NO_MATRIX=$NO_MATRIX | ||
MATRIX_URL=$MATRIX_URL | ||
MATRIX_USER=$MATRIX_USER | ||
MATRIX_PASSWORD=$MATRIX_PASSWORD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package actions | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ipfs/kuboreleaser/util" | ||
) | ||
|
||
type Env struct{} | ||
|
||
//go:embed embed/.env.sh | ||
var envScript string | ||
|
||
//go:embed embed/.env.template | ||
var envTemplate string | ||
|
||
func (ctx Env) Check() error { | ||
if _, err := os.Stat(".env"); os.IsNotExist(err) { | ||
return fmt.Errorf("file .env does not exist yet in the current directory (%w)", ErrIncomplete) | ||
} | ||
return nil | ||
} | ||
|
||
func (ctx Env) Run() error { | ||
envScriptFile, err := os.CreateTemp("", ".env.*.sh") | ||
if err != nil { | ||
return err | ||
} | ||
_, err = envScriptFile.WriteString(envScript) | ||
if err != nil { | ||
return err | ||
} | ||
err = os.Chmod(envScriptFile.Name(), 0755) | ||
if err != nil { | ||
return err | ||
} | ||
envTemplateFile, err := os.CreateTemp("", ".env.*.sh") | ||
if err != nil { | ||
return err | ||
} | ||
_, err = envTemplateFile.WriteString(envTemplate) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd := util.Command{ | ||
Name: envScriptFile.Name(), | ||
Stdin: os.Stdin, | ||
Env: append(os.Environ(), fmt.Sprintf("ENV_TEMPLATE=%s", envTemplateFile.Name())), | ||
} | ||
err = cmd.Run() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.