Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/scripts/update_nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# edit version in package.nix
sed -i "s/version = \".*\"/version = \"$VERSION\"/" package.nix

#x86 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-x86_64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
SANITIZE_HASH=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$NEW_HASH")
sed -zi "s/sha256 = \".*\"/sha256 = \"${SANITIZE_HASH}\"/1m" package.nix

#aarch64 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-aarch64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
SANITIZE_HASH=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$NEW_HASH")
sed -zi "s/sha256 = \".*\"/sha256 = \"${SANITIZE_HASH}\"/2m" package.nix

#x86 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-x86_64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
SANITIZE_HASH=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$NEW_HASH")
sed -zi "s/sha256 = \".*\"/sha256 = \"${SANITIZE_HASH}\"/3m" package.nix

#aarch64 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-aarch64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
SANITIZE_HASH=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$NEW_HASH")
sed -zi "s/sha256 = \".*\"/sha256 = \"${SANITIZE_HASH}\"/4m" package.nix

if [ -z "$GITHUB_OUTPUT" ]; then
echo $(cat package.nix) >>$GITHUB_OUTPUT
else
cat package.nix
fi
57 changes: 57 additions & 0 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,60 @@ jobs:
git checkout -b docs-production origin/docs-production
git reset --hard origin/main
git push --force-with-lease
update-nix:
name: Update glide nix flake
runs-on: ubuntu-latest

steps:
- name: install nix
uses: DeterminateSystems/determinate-nix-action@1d699fc25db3f9e079cd2f168ca007a4183389be # or v3.15.1 to pin to a release

- name: clone glide.nix repo
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
persist-credentials: true
repository : "glide-browser/glide.nix"

- name: update hashes
Comment thread
nixith marked this conversation as resolved.
env:
VERSION: inputs.tag_name || ${{ github.event.release.tag_name }}
Comment thread
nixith marked this conversation as resolved.
Outdated
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GITHUB_TOKEN isn't set in the secrets for this repo, I think this should work

Suggested change
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}

run: |
git switch -c "update-$VERSION"
.github/scripts/update_nix.sh
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually just realised this won't work because you're only checking out the glide.nix repo.

either the script could live in glide.nix or you'd have to checkout the glide repo and glide.nix to different directories

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need any data from the glide repo? It could always live in glide.nix (and would make this easier). There would just have to be a trigger on the glide.nix side, either a webhook from here or some other github actions knowledge I'm unfamiliar with

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it'd make sense for the script to live in glide.nix at a minimum.

I'm not aware of a nice builtin way to do cross-repo webhooks without having to host a server in the middle.

So the options in my mind are:

  1. Move script to glide.nix, keep the workflow that runs the script / creates the PR in this repo
  2. Move script to glide.nix, this post-release workflow then invokes a workflow defined in glide.nix (you could do this with workflow_dispatch, maybe even workflow_call I'd need to double check)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking into this I think the best bet we have is moving forward with option 2 (simplified my work a lot, I can use the actions you mentioned) and using the github cli to do workflow_dispatch. workflow_call could work, but there's some need for orginizational level changes there and I'm not entirely sure what context this sort of thing executes in (i.e. would the pull action pull from here, or from glide.nix)

# edit version in package.nix
sed -i 's/version = ".*"/version = "$VERSION"/' package.nix

#x86 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-x86_64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/1m' package.nix

#aarch64 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-aarch64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/2m' package.nix

#x86 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-x86_64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/3m' package.nix

#aarch64 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-aarch64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/4m' package.nix

Comment on lines +51 to +73
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should all be in the script now?

Suggested change
# edit version in package.nix
sed -i 's/version = ".*"/version = "$VERSION"/' package.nix
#x86 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-x86_64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/1m' package.nix
#aarch64 linux
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.linux-aarch64.tar.xz"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/2m' package.nix
#x86 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-x86_64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/3m' package.nix
#aarch64 macos
RELEASE_LINK="https://github.com/glide-browser/glide/releases/download/$VERSION/glide.macos-aarch64.dmg"
NEW_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url "$RELEASE_LINK"))
sed -zi 's/sha256 = ".*"/sha256 = "$NEW_HASH"/4m' package.nix


# modification done
git add package.nix
git commit -m "update: v$VERSION"

# make pull request
gh -R "glide-browser/glide.nix" pr create --title "update to version $VERSION" --body "" --head "$update-$VERSION"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't push the branch for you because you're passing --head, so you need

Suggested change
gh -R "glide-browser/glide.nix" pr create --title "update to version $VERSION" --body "" --head "$update-$VERSION"
git push origin "update-$VERSION"
gh -R "glide-browser/glide.nix" pr create --title "update to version $VERSION" --body "" --head "update-$VERSION"


# auto-merge
gh -R "glide-browser/glide.nix" pr merge "update-$VERSION" --auto --rebase
#TODO: check if this works

Loading