Skip to content

Commit

Permalink
Set app version on build
Browse files Browse the repository at this point in the history
Fix bug with removing "about" in profile editor
  • Loading branch information
hzrd149 committed Oct 12, 2024
1 parent bb855a2 commit fc8c758
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-goats-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nostrudel": patch
---

Fix bug with removing "about" in profile editor
21 changes: 5 additions & 16 deletions .github/workflows/deploy-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
7 changes: 5 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/components/version-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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={() => {
Expand All @@ -23,7 +23,7 @@ export default function VersionButton({ ...props }: Omit<ButtonProps, "children"
}}
{...props}
>
Version: {version}
{version}
</Button>
);
}
8 changes: 4 additions & 4 deletions src/views/profile/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit fc8c758

Please sign in to comment.