Skip to content

Commit

Permalink
ci: adding automated release creating
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperC286 committed May 18, 2023
1 parent 1236a8a commit edd6de0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/releasing.yml
@@ -0,0 +1,20 @@
name: Releasing
on:
push:
branches: [main]
permissions:
contents: write
jobs:
Releasing:
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.7.5.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.5/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Releasing.
run: earthly --ci --secret GH_TOKEN +releasing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub Actions.
11 changes: 11 additions & 0 deletions Earthfile
Expand Up @@ -175,3 +175,14 @@ unit-testing:
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/unit-testing.sh


releasing:
FROM ubuntu
RUN apt-get update
RUN apt-get install wget git -y
RUN wget https://github.com/cli/cli/releases/download/v2.29.0/gh_2.29.0_linux_amd64.tar.gz
RUN tar -xzvf gh_2.29.0_linux_amd64.tar.gz
RUN cp ./gh_2.29.0_linux_amd64/bin/gh /bin/gh
DO +COPY_METADATA
RUN --secret GH_TOKEN ./ci/releasing.sh
18 changes: 18 additions & 0 deletions ci/releasing.sh
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

# Get current version.
current_version=$(cat "VERSION")
# If the tag already exist then exit.
git tag -l | grep -q "^${current_version}$" && exit 0
# Where to start generating the release description from.
base_commit=$(git rev-list --max-parents=0 HEAD)
# latest_tag=$(git tag --sort=committerdate | tail -1)
# latest_tag=$(git show ${_arg_from_reference}:VERSION)
description_from="${latest_tag:-${base_commit}}"
# Generate the release description.
release_description=$(git log --format="* %s" ${description_from}.. --no-merges)
# Create release and the tag.
gh release create "${current_version}"

0 comments on commit edd6de0

Please sign in to comment.