Skip to content

Commit

Permalink
feat: Sign releases
Browse files Browse the repository at this point in the history
  • Loading branch information
andymac4182 committed Apr 21, 2023
1 parent b6f5bf2 commit 06ddd88
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
46 changes: 46 additions & 0 deletions .build/sign-release.sh
@@ -0,0 +1,46 @@
#!/bin/bash

# Set variables
repo_owner="obsidian-confluence"
repo_name="obsidian-confluence"
version="$1"

if [ -z "$version" ]; then
echo "Please provide a version number as an argument"
exit 1
fi

prefixes=(
""
"obsidian-confluence"
"obsidian-confluence-root"
"@markdown-confluence/lib"
"@markdown-confluence/mermaid-electron-renderer"
)

mkdir -p .artifacts
cd .artifacts

for prefix in "${prefixes[@]}"; do
# Add a '-' only if the prefix is not empty
if [ -n "$prefix" ]; then
prefix_with_dash="$prefix-v"
else
prefix_with_dash=""
fi

# Create download URL
tag="${prefix_with_dash}$version"
download_url="https://github.com/$repo_owner/$repo_name/archive/refs/tags/$tag.tar.gz"
file_name="$tag.tar.gz"

# Download the tar.gz file
curl -L -o "$file_name" "$download_url"

# Sign the tar.gz file
gpg --armor --detach-sign "$file_name"

gh release upload $tag $file_name

echo "Signature for $tag uploaded to to https://github.com/obsidian-confluence/obsidian-confluence/releases/tag/$tag"
done
27 changes: 27 additions & 0 deletions .build/upload-release-assets.sh
@@ -0,0 +1,27 @@
#!/bin/bash

ORIGINAL_TAG="$1"
SHA="$2"

ORIGINAL_PATH=$PWD

mkdir -p packages/obsidian/dist/
cp README.md packages/obsidian/dist/
cp manifest.json packages/obsidian/dist/

npm ci
npm run lint -ws --if-present
npm run prettier-check -ws --if-present
npm run build -ws --if-present

IFS='-v' read -ra PARTS <<< "$ORIGINAL_TAG"
TAG="${PARTS[-1]}"

cd packages/obsidian

FILES=$(echo dist/*)
gh release create $TAG -t $TAG --generate-notes --latest --target $SHA ./dist/*
echo $FILES

cd $ORIGINAL_PATH
./.build/sign-release $TAG
21 changes: 1 addition & 20 deletions .github/workflows/release-please.yml
Expand Up @@ -36,26 +36,7 @@ jobs:

- name: Upload release assets
if: ${{ steps.release-please.outputs.release_created }}
run: |
mkdir -p packages/obsidian/dist/
cp README.md packages/obsidian/dist/
cp manifest.json packages/obsidian/dist/
npm ci
npm run lint -ws --if-present
npm run prettier-check -ws --if-present
npm run build -ws --if-present
ORIGINAL_TAG=${{ steps.release-please.outputs.tag_name }}
IFS='-v' read -ra PARTS <<< "$ORIGINAL_TAG"
TAG="${PARTS[-1]}"
cd packages/obsidian
zip -r ${{ github.event.repository.name }}-$TAG.zip dist
FILES=$(echo dist/*)
gh release create $TAG -t $TAG --generate-notes --latest --target ${{ steps.release-please.outputs.sha }} ./dist/*
echo $FILES
run: ./.build/upload-release-assets.sh ${{ steps.release-please.outputs.tag_name }} ${{ steps.release-please.outputs.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
Expand Down

0 comments on commit 06ddd88

Please sign in to comment.