It's a blog

Tag: short

Delete all Github releases, using the Github cli

If you are like me, at some point while developing projects on Github you will have started and stopped using releases, opting to switch back to only creating tags.

Github defaults leave you in a bit of an awkward position here where the “Releases” section in the side bar will continue to show your old releases, even if you have made hundreds of tags since.

If you’re managing lots of repositories and have made lots of legacy releases, removing them can be a pain (particularly in the UI). So, once again, GitHub CLI to the rescue!

In the repository of your choice run the following, and all of your releases will be removed!

gh release list | awk '{print $1;}' | xargs -L1 gh release delete
Code language: JavaScript (javascript)

If you want to see them ahead of removing them, list them first.

gh release list
Code language: PHP (php)

Enjoy your time saving, and your nice clear releases list!

Github repo settings sync, using the Github cli

The number of Github repositories that I end up maintaining in one way or another ends up growing week by week. And keeping all of the descriptions and settings up to date in sync can be painful todo by hand.

A little while ago I migrated my addwiki project to use a monorepo, and thus needed to bulk update all of the github repository descriptions. While doing so I made use of the github cli and created a single bash script to let me configure all of the repositories at once.

Assuming you already have the github cli install and configured getting started with this is easy.

The command

The below command is one of many in my bash script for repo configuration. This sets a description, homepage and various other flags that I want to be consistent across repositories.

gh api --method PATCH repos/addwiki/addwiki \ --field description='Monorepo containing all addwiki libraries, packages and applications'\ --field homepage='https://addwiki.github.io/'\ --field has_issues='true'\ --field has_projects='false'\ --field has_wiki='false'
Code language: JavaScript (javascript)
Continue reading

Resizing a qemu image root disk partition

Recently I found myself altering some virtual images for loading onto a qemu machine. I wanted to increase the disk space on the root partition, but couldn’t find any straightforward guides. So here is a little guide for future me, and anyone else.

Install libguestfs-tools

libguestfs is a set of tools for accessing and modifying virtual machine (VM) disk images. You can find details in the docs.

apt-get install libguestfs-tools
Code language: JavaScript (javascript)

Create a new resized image

First you need to create a new empty image of the size that you want.

For me that is 20GB

truncate -s 20G ./out.img

Then use virt-resize to expand the existing disk to fill all of the space in the new image that we created. (virt-resize docs)

virt-resize --expand /dev/sda1 ./vm.img ./out.img

Verify it worked

libguestfs-tools also provides a way to view file system information by only using the image file. (virt-filesystems docs)

virt-filesystems --long --parts --blkdevs -h -a ./out.img

You’ll see something like this:

Name Type MBR Size Parent /dev/sda1 partition 83 20G /dev/sda /dev/sda device - 20G -
Code language: PHP (php)

© 2021 Addshore

Theme by Anders NorénUp ↑