-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add versioning and release branches to cicd
- Loading branch information
1 parent
596c8f3
commit 3708029
Showing
7 changed files
with
311 additions
and
12 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,23 @@ | ||
name: Build Dev | ||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: [ "main" ] | ||
jobs: | ||
|
||
buildDeployDev: | ||
uses: ./.github/workflows/build.yml | ||
secrets: | ||
GH_PAT: ${{ secrets.GH_PAT }} | ||
GPG_PRIVATE_KEY2: ${{ secrets.GPG_PRIVATE_KEY2 }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY }} | ||
UNS_API_KEY: ${{ secrets.UNS_API_KEY }} | ||
SIMPLE_HASH_API_KEY: ${{ secrets.SIMPLE_HASH_API_KEY }} | ||
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }} | ||
POAP_API_KEY: ${{ secrets.POAP_API_KEY }} | ||
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
with: | ||
update_version_command: npm version prerelease --preid=pre --no-git-tag-version | ||
update_version: false |
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 |
---|---|---|
@@ -1,12 +1,91 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
tags: | ||
- v* | ||
workflow_call: | ||
inputs: | ||
update_version_command: | ||
required: false | ||
type: string | ||
default: npm version patch | ||
update_version: | ||
required: true | ||
type: boolean | ||
default: true | ||
branch: | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
secrets: | ||
GH_PAT: | ||
description: 'needed for github login' | ||
required: true | ||
GPG_PRIVATE_KEY2: | ||
description: 'needed for gpg key' | ||
required: true | ||
GPG_KEY_ID: | ||
description: 'needed for gpg key' | ||
required: true | ||
ALCHEMY_API_KEY: | ||
description: 'needed for alchemy' | ||
required: true | ||
BLOCKNATIVE_API_KEY: | ||
description: 'needed for blocknative' | ||
required: true | ||
UNS_API_KEY: | ||
description: 'needed for uns' | ||
required: true | ||
SIMPLE_HASH_API_KEY: | ||
description: 'needed for simple hash' | ||
required: true | ||
ZEROX_API_KEY: | ||
description: 'needed for zerox' | ||
required: true | ||
POAP_API_KEY: | ||
description: 'needed for poap' | ||
required: true | ||
DAYLIGHT_API_KEY: | ||
description: 'needed for daylight' | ||
required: true | ||
|
||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
ssh-key: ${{ secrets.GH_PAT }} | ||
|
||
- name: Import GPG Key | ||
if: ${{ inputs.update_version }} | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
run: | | ||
echo "$GPG_PRIVATE_KEY" | gpg --import | ||
git config --global user.signingkey $GPG_KEY_ID | ||
git config --global commit.gpgsign true | ||
# Configure Git with CI account details | ||
git config --global user.name "ci-dominantstrategies" | ||
git config --global user.email "[email protected]" | ||
# Optionally, check that the GPG key is correctly configured for signing | ||
gpg --list-keys "[email protected]" | ||
- name: Install yq | ||
run: sudo snap install yq | ||
|
||
- name: get Version | ||
run: | | ||
VERSION_VALUE=$(sudo yq eval '.version' package.json | head -n 1) | ||
echo "VERSION=$VERSION_VALUE" | ||
echo "VERSION=$VERSION_VALUE" >> $GITHUB_ENV | ||
- name: git tag | ||
if: ${{ inputs.update_version }} | ||
run: git tag ${{ env.VERSION }} && HUSKY=0 git push origin tag ${{ env.VERSION }} | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -42,14 +121,14 @@ jobs: | |
- run: yarn install --frozen-lockfile | ||
- name: Detect env block | ||
id: env-block | ||
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') | ||
if: ${{ !inputs.update_version }} | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const detectEnvBlock = require("./.github/workflows/builds/detect-env-block.js") | ||
return await detectEnvBlock({ github, context }) | ||
- name: Dev build | ||
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') | ||
if: ${{ !inputs.update_version }} | ||
run: | | ||
echo -e ${{ steps.env-block.outputs.result }} > .env | ||
echo 'USE_ANALYTICS_SOURCE="BETA"' >> .env | ||
|
@@ -60,7 +139,7 @@ jobs: | |
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
COMMIT_SHA: ${{ github.sha }} | ||
- name: Production build | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | ||
if: ${{ inputs.update_version }} | ||
run: | | ||
echo 'USE_ANALYTICS_SOURCE="PROD"' >> .env | ||
yarn build | ||
|
@@ -74,19 +153,49 @@ jobs: | |
POAP_API_KEY: ${{ secrets.POAP_API_KEY }} | ||
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
- name: Upload build asset | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
if: ${{ inputs.update_version }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: extension-builds-${{ github.event.number || github.event.head_commit.id }} | ||
path: dist/*.zip | ||
- name: Create Release and Upload Artifacts | ||
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
if: ${{ inputs.update_version }} | ||
with: | ||
files: dist/*.zip | ||
draft: true | ||
generate_release_notes: true | ||
prerelease: ${{ contains(github.ref, '-pre') || contains(github.ref, 'v0.') }} | ||
prerelease: false | ||
- name: Install jq | ||
if: ${{ inputs.update_version }} | ||
run: sudo apt-get update && sudo apt-get install -y jq | ||
- name: install semver globally | ||
if: ${{ inputs.update_version }} | ||
run: npm install -g semver | ||
- name: Update Version | ||
if: ${{ inputs.update_version }} | ||
run: ${{ inputs.update_version_command }} | ||
- name: get Version | ||
if: ${{ inputs.update_version }} | ||
run: | | ||
VERSION_VALUE=$(sudo yq eval '.version' package.json | head -n 1) | ||
echo "VERSION=$VERSION_VALUE" | ||
echo "VERSION=$VERSION_VALUE" >> $GITHUB_ENV | ||
- name: Sync Manifest | ||
if: ${{ inputs.update_version }} | ||
run: | | ||
yq eval -i ".version = \"${{ env.VERSION }}\"" manifest/manifest.json | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
if: ${{ inputs.update_version }} | ||
with: | ||
branch: ${{ inputs.branch }} | ||
commit_user_name: ci-dominantstrategies | ||
commit_user_email: [email protected] | ||
env: | ||
HUSKY: 0 | ||
|
||
|
||
|
||
## test: | ||
## runs-on: ubuntu-latest | ||
## steps: | ||
|
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,122 @@ | ||
name: Cut a new Minor Release Branch | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Branch to use' | ||
required: true | ||
default: 'main' | ||
|
||
jobs: | ||
|
||
cutReleaseCandidateTS: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
branch: ${{ steps.set-branch.outputs.branch }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ssh-key: ${{ secrets.GH_PAT }} | ||
|
||
- name: Import GPG Key | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
run: | | ||
echo "$GPG_PRIVATE_KEY" | gpg --import | ||
git config --global user.signingkey $GPG_KEY_ID | ||
git config --global commit.gpgsign true | ||
# Configure Git with CI account details | ||
git config --global user.name "ci-dominantstrategies" | ||
git config --global user.email "[email protected]" | ||
# Optionally, check that the GPG key is correctly configured for signing | ||
gpg --list-keys "[email protected]" | ||
- name: Install jq | ||
if: ${{ inputs.update_version }} | ||
run: sudo apt-get update && sudo apt-get install -y jq | ||
|
||
- name: Set Repo Name in Camel Case | ||
run: | | ||
repo_name=$(basename ${{ github.repository }}) | ||
if [ -n "${{ inputs.name_override }}" ]; then | ||
repo_name=${{ inputs.name_override }} | ||
fi | ||
camel_case_name=$(echo $repo_name | awk -F- '{for(i=2; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2); }1' OFS="") | ||
echo "CAMEL_CASE_REPO_NAME=$camel_case_name" >> $GITHUB_ENV | ||
- name: Install Volta | ||
run: | | ||
curl -sSLf https://get.volta.sh | bash | ||
echo "$HOME/.volta/bin" >> $GITHUB_PATH | ||
- name: Log Node and Npm Versions | ||
run: | | ||
echo node version $(node -v) | ||
echo npm version $(npm -v) | ||
- name: install semver globally | ||
if: ${{ inputs.update_version }} | ||
run: npm install -g semver | ||
|
||
- name: Update Version | ||
if: ${{ inputs.update_version }} | ||
run: | | ||
jq --arg new_version "v$(npx semver -i patch $(jq -r '.version' package.json | sed 's/^v//'))" '.version = $new_version' package.json > temp.json && mv temp.json package.json | ||
NEW_VERSION=$(jq -r '.version' package.json) | ||
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Update version environment variable | ||
run: echo "VERSION=$(echo $VERSION | sed 's/\.[0-9]*$//')" >> $GITHUB_ENV | ||
|
||
- name: Store version in branch variable | ||
id: set-branch | ||
run: echo "branch=${{ env.VERSION }}" >> $GITHUB_OUTPUT | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Release ${{ env.VERSION }} | ||
branch: ${{ env.VERSION }} | ||
create_branch: true | ||
commit_user_name: ci-dominantstrategies | ||
commit_user_email: [email protected] | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
ssh-key: ${{ secrets.GH_PAT }} | ||
|
||
- name: Update Version | ||
run: | | ||
jq --arg new_version "v$(npx semver -i minor $(jq -r '.version' package.json | sed 's/^v//;s/-pre$//'))-pre" '.version = $new_version' package.json > temp.json && mv temp.json package.json | ||
NEW_VERSION=$(jq -r '.version' package.json) | ||
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Sync package-lock.json | ||
run: npm i --package-lock-only --ignore-scripts | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Rev'd main to Release ${{ env.VERSION }} | ||
branch: ${{ inputs.branch }} | ||
commit_user_name: ci-dominantstrategies | ||
commit_user_email: [email protected] | ||
|
||
deployReleaseCandidateTS: | ||
uses: ./.github/workflows/build.yml | ||
secrets: | ||
GH_PAT: ${{ secrets.GH_PAT }} | ||
GPG_PRIVATE_KEY2: ${{ secrets.GPG_PRIVATE_KEY2 }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY }} | ||
UNS_API_KEY: ${{ secrets.UNS_API_KEY }} | ||
SIMPLE_HASH_API_KEY: ${{ secrets.SIMPLE_HASH_API_KEY }} | ||
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }} | ||
POAP_API_KEY: ${{ secrets.POAP_API_KEY }} | ||
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
|
||
with: | ||
update_version_command: "jq --arg new_version \"v$(npx semver -i patch $(jq -r '.version' package.json | sed 's/^v//'))\" '.version = $new_version' package.json > temp.json && mv temp.json package.json" | ||
update_version: true | ||
branch: ${{ needs.cutReleaseCandidateTS.outputs.branch }} |
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,25 @@ | ||
name: Build Sandbox | ||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- 'v?[0-9]+.[0-9]+' | ||
jobs: | ||
|
||
buildDeployDev: | ||
uses: ./.github/workflows/build.yml | ||
secrets: | ||
GH_PAT: ${{ secrets.GH_PAT }} | ||
GPG_PRIVATE_KEY2: ${{ secrets.GPG_PRIVATE_KEY2 }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY }} | ||
UNS_API_KEY: ${{ secrets.UNS_API_KEY }} | ||
SIMPLE_HASH_API_KEY: ${{ secrets.SIMPLE_HASH_API_KEY }} | ||
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }} | ||
POAP_API_KEY: ${{ secrets.POAP_API_KEY }} | ||
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
with: | ||
update_version_command: "jq --arg new_version \"v$(npx semver -i patch $(jq -r '.version' package.json | sed 's/^v//'))\" '.version = $new_version' package.json > temp.json && mv temp.json package.json" | ||
update_version: false | ||
|
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,20 @@ | ||
name: Patch | ||
on: workflow_dispatch | ||
jobs: | ||
|
||
buildDeployDev: | ||
uses: ./.github/workflows/build.yml | ||
secrets: | ||
GH_PAT: ${{ secrets.GH_PAT }} | ||
GPG_PRIVATE_KEY2: ${{ secrets.GPG_PRIVATE_KEY2 }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY }} | ||
UNS_API_KEY: ${{ secrets.UNS_API_KEY }} | ||
SIMPLE_HASH_API_KEY: ${{ secrets.SIMPLE_HASH_API_KEY }} | ||
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }} | ||
POAP_API_KEY: ${{ secrets.POAP_API_KEY }} | ||
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }} | ||
with: | ||
update_version_command: "jq --arg new_version \"v$(npx semver -i patch $(jq -r '.version' package.json | sed 's/^v//'))\" '.version = $new_version' package.json > temp.json && mv temp.json package.json" | ||
update_version: true |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@pelagus/pelagus-extension", | ||
"private": true, | ||
"version": "0.2.11", | ||
"version": "v0.2.11", | ||
"description": "Pelagus, the community owned and operated Web3 wallet for Quai Network.", | ||
"main": "index.js", | ||
"repository": "[email protected]:PelagusWallet/pelagus-extension.git", | ||
|