Set app version on build

Fix bug with removing "about" in profile editor
This commit is contained in:
hzrd149 2024-10-12 11:11:01 +01:00
parent bb855a2f8f
commit fc8c758e82
8 changed files with 27 additions and 28 deletions

View File

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Fix bug with removing "about" in profile editor

View File

@ -11,9 +11,6 @@ concurrency:
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
@ -29,24 +26,16 @@ jobs:
- name: Install Dependencies
run: pnpm install
- name: Set build env
run: |
echo "VITE_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
- name: Build
run: pnpm build
- name: Redirect 404 to Index for SPA
run: cp dist/index.html dist/404.html
# - name: Deploy
# uses: reggionick/s3-deploy@v4
# with:
# folder: dist
# bucket: "${{ secrets.S3_BUCKET }}"
# bucket-region: us-east-1
# dist-id: "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}"
# invalidation: /
# delete-removed: true
# no-cache: true
# private: true
# files-to-include: "{.*/**,**}"
- name: Deploy nsite
run: npx -y nsite-cli upload dist --verbose --purge --privatekey ${{ secrets.NSITE_KEY }}

View File

@ -50,8 +50,8 @@ jobs:
- name: Set build env
run: |
echo "VITE_COMMIT_HASH=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
@ -61,3 +61,6 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
COMMIT_HASH=$COMMIT_HASH
APP_VERSION=$APP_VERSION

View File

@ -45,7 +45,7 @@ jobs:
- name: Set build env
run: |
echo "VITE_COMMIT_HASH=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
echo "VITE_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
- name: Build

View File

@ -16,8 +16,10 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ENV VITE_COMMIT_HASH=""
ENV VITE_APP_VERSION="Custom"
ARG COMMIT_HASH=""
ARG APP_VERSION=""
ENV VITE_COMMIT_HASH="$COMMIT_HASH"
ENV VITE_APP_VERSION="$APP_VERSION"
COPY tsconfig.json .
COPY index.html .

View File

@ -9,7 +9,7 @@
},
"scripts": {
"start": "vite serve",
"dev": "VITE_APP_VERSION=production vite serve",
"dev": "VITE_APP_VERSION=dev vite serve",
"build": "tsc --project tsconfig.json && vite build",
"format": "prettier --ignore-path .prettierignore -w .",
"analyze": "npx vite-bundle-visualizer -o ./stats.html",

View File

@ -11,7 +11,7 @@ export default function VersionButton({ ...props }: Omit<ButtonProps, "children"
return (
<Button
variant="outline"
variant="link"
size="sm"
rightIcon={copied ? <CheckIcon /> : <CopyToClipboardIcon />}
onClick={() => {
@ -23,7 +23,7 @@ export default function VersionButton({ ...props }: Omit<ButtonProps, "children"
}}
{...props}
>
Version: {version}
{version}
</Button>
);
}

View File

@ -224,10 +224,10 @@ export const ProfileEditView = () => {
picture: data.picture,
banner: data.banner,
};
if (data.displayName) newMetadata.displayName = newMetadata.display_name = data.displayName;
if (data.about) newMetadata.about = data.about;
if (data.website) newMetadata.website = data.website;
if (data.nip05) newMetadata.nip05 = data.nip05;
if (data.displayName !== undefined) newMetadata.displayName = newMetadata.display_name = data.displayName;
if (data.about !== undefined) newMetadata.about = data.about;
if (data.website !== undefined) newMetadata.website = data.website;
if (data.nip05 !== undefined) newMetadata.nip05 = data.nip05;
if (data.lightningAddress) {
if (isLNURL(data.lightningAddress)) {