Zip Code Base with Github Actions for Releases
The original post can be found here.
In this tutorial, we will use Github Actions to zip the code base and create a new release with it.
Code Base Setup
You will need a Github repository and access to Github Actions. First step, clone your repository and switch into it. We will begin to create empty files in the folder. These files represent a simple app.
touch README.md
touch main.py
touch .gitignore
Push the changes to the master branch.
git add --all
git commit -m "Added basic files"
git push
Workflow Setup
We will use the zip
command: zip -r release.zip .
. This is zip into a file called release.zip
and zip up the current directory (.
).
Create a workflow here:
mkdir -p ./.github/workflows/
touch ./.github/workflows/master.yml
The contents should be:
name: MasterDeployCI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Zip Folder
run: zip -r release.zip .
- name: Release to Github
run: echo "Release"
Then push your changes to the remote repository:
git add --all
git commit -m "Added workflow for master"
git push

As you can see it worked, but we zipped too much. We don’t want to zip the .git
folder, the .github
folder or the .gitignore
file.
We can use -x
. We can also test this locally (if on Ubuntu or OSx):

name: MasterDeployCI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Zip Folder
run: zip -r release.zip . -x ".git/*" ".github/*"
- name: Release to Github
run: echo "Release"
Release
We are going to use this release/tagging. You can look at this this release/taggingawesome list of actions for a range of actions.
Update the workflow to be:
name: MasterDeployCI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create Release Folder
run: rsync -arv --exclude='.git/' --exclude='.github/' --exclude='.gitignore' . ./release
- name: Switch to Release Folder
run: |
cd release
ls -la
- name: Bump version and push tag
uses: anothrNick/github-tag-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: keithweaver



You can download the source code.
Thanks for reading! Follow me for more.