Git Command Line Snippets: Upload Release Asset

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Now that we have the json from GitHub for the release, we can upload the release zip (an extra asset) which is used for installing the plugin on a ClassicPress site:

curl -X POST --header "Authorization: token ghp_authorizationtoken" --header "Content-Type: application/zip" --upload-file "path and filename" "https://uploads.github.com/repos/username/repository name/releases/tag id/assets?name=filename"

The highlighted sections need to be replaced with the parameters for your GitHub account, repo and the release.

Git Command Line Snippets: Get Release Information

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

In the last post, of this series, I covered the command to create a release and mentioned that uploading a release zip (extra asset) had to be handled separately. While the command to do this isn’t too complex, there is one problem; to upload the asset you need the tag d of the release. This is not the tag that you supply to create the release with, but the internal GitHub id which is automatically assigned.

The command below can be used to get the release information, in the form of json, which includes the tag id:

curl -H "Accept: application/vnd.github+json" -H "Authorization: token ghp_authorizationtoken" https://api.github.com/repos/username/repository name/releases/tags/required tag

Git Command Line Snippets: Create Release

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Once changes have been added, committed and pushed to the repository, we can create a release.

When developing for ClassicPress, there is also a need to upload a release zip which is used for deployment to a ClassicPress site. Unfortunately, this cannot be done while creating a release; this post is just on creating the release and a later post will cover uploading the release zip.

The following command can be used to create a release using command line:

curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token ghp_authorizationtoken" https://api.github.com/repos/username/repository name/releases -d "{\"tag_name\":\"tagname\",\"target_commitish\":\"main\",\"name\":\"name\",\"body\":\"release comment\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false}"

The highlighted sections need to be replaced with the parameters for your GitHub account and repo.

Git Command Line Snippets: Add, Commit and Push Changes

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

There are three steps required to add your changes to a GitHub repository:

  1. Add
  2. Commit
  3. Push

Fistly, you need to add your changes; it is possible to only add specific files, but in my case I always want to add everything; this command will add all changes including added changed or deleted files and folders:

git add --all

Once you have added the changes, you need to commit them; you can supply a commit message, but this should be a maximum of 55 characters.

git commit -m "Release for x and y"

Once you have committed the changes, you need to push them to GitHub for them to appear in the repository:

git push

Git Command Line Snippets: Choose Repository

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

I am new to working with the git command line so have spent a bit of time reading articles. One thing a lot of them say is to “choose your repository” and then tell you to run commands. When I was doing this it was a bit late and I’d been working all day (getting my excuse in early), but I didn’t immediately understand what they meant.

All it means when they say to choose your repository, is to navigate the command prompt to the repository folder on your computer.

In command line you can simply use cd followed by the path: to navigate to the required folder

cd C:\Users\azurecurve\Documents\Development\ClassicPress Development\azrcrv-smtp

In PowerShell you can largely do the same thing but must wrap the path in double quotes if the path contains a space:

cd "C:\Users\azurecurve\Documents\Development\ClassicPress Development\azrcrv-smtp"

Git Command Line Snippets: Update Name and Email

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Before you start using Git you need to enter your credentials to identify yourself as the author. The name and email address should both be set to the same as the ones you use in GitHub.

To set your username you can use this command:

git config --global user.name "azurecurve"

To set your email address you can use this command:

git config --global user.email "github@example.co.uk"

Git Command Line Snippets: Series Index

GitHubBack in April 2020, I did a series on using GitHub when developing for ClassicPress. More recently I have started to take a look at using the git command line to help automate making commits, releases and other actions. I’ m going to use this git snippets series to record the commands I have been using.

You can use an ordinary Windows command prompt or PowerShell to run git commands; I started out using command line, but did move onto running them in PowerShell as soon as I wanted to run commands sequentially.

If you’re reading this post on azurecurve | Ramblings of an IT Professional, then the post will automatically refresh otherwise check Git Command Line Snippets for new posts.

Continue reading “Git Command Line Snippets: Series Index”

GitHub make licensing changes with all core features now free for everyone

GitHubGit hub have recently announced changes to their licensing, so that everyone now has free access to all core features. This includes unlimited collaborators in private repositories.

The key changes are:

  • GitHub Free for organizations is immediately available and includes private repositories for unlimited users
  • All organizations previously using Team for Open Source now have GitHub Free
  • GitHub Free for individual developers now includes unlimited collaborators
  • Organizations and individuals using GitHub Free will receive GitHub Community Support
  • GitHub Pro will now include 2GB of Packages storage and 10GB of data transfer
  • GitHub Pro now has reduced the monthly price from $7 to $4
  • GitHub Team now has reduced the monthly price $7 to $4 per user with no minimum seat requirement
  • GitHub Team will include 3,000 Actions minutes per month for private repositories after May 14

All details on the changes are available from the FAQ about changes to GitHub’s plans.

ClassicPress Development with GitHub: Creating release zips

GitHubWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with GitHub.

In the last post of this series, when discussing creating a release, I mentioned that you should upload a zip file containing the release code.

While users can download the source code directly, this will leave -master on the folder name. By creating a release zip, you can avoid this.

I have developed quite a few plugins for ClassicPress and have instances where I make changes to several plugins for release at the same time. To make this easier, I have a Windows batch command which will call 7-zip to compress all folders, in the same folder as the batch file, as zip files:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a -xr!.git\ -xr!*~ "%%X.zip" "%%X\"

I didn’t create this command line statement all on my own, but think I might have added the argument to exclude files with a .git suffix. Unfortunately, I started using it a few months ago and do not remember from where the original script came.

ClassicPress Development with GitHub: Create Release

GitHubWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with GitHub.

When developing with GitHub, you can make a release; this is a way of grouping together all of the changes since the last release to make it easy to download that particular code set. One point to note, is that while GitHub will automatically create a zip of the source code, this isn’t suitable to use for a ClassicPress release as it will include -master in the contained directory name. However, you can upload a zip file containing the code in the correct folder.

To create a new release, load the repository page on GitHub and click the releases button (red ringed):

Repository page

Continue reading “ClassicPress Development with GitHub: Create Release”