Skip to content

Commit

Permalink
feat: add action
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Sep 21, 2020
1 parent 75b5daa commit e65a1cc
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/release-action.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use latest alpine image as base
FROM alpine:latest

# Copy needed stuff into container
COPY LICENSE README.md /
COPY entrypoint.sh /entrypoint.sh

# Install some packages
RUN apk add jq bash git go
RUN apk add --no-cache --upgrade grep

# Start action
ENTRYPOINT ["/entrypoint.sh"]
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "PTerm Release"
description: "Creates a new release if the PTerm version has changed in a commit."
author: "MarvinJWendt"
branding:
icon: award
color: orange
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.myInput }}
56 changes: 56 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -e

REPO_FULLNAME=$(jq -r ".repository.full_name" "$GITHUB_EVENT_PATH")

echo "## Initializing git repo..."
git init
echo "### Adding git remote..."
git remote add origin https://x-access-token:$ACCESS_TOKEN@github.com/$REPO_FULLNAME.git
echo "### Getting branch"
BRANCH=${GITHUB_REF#*refs/heads/}

if [[ $BRANCH == refs/tags* ]]; then
echo "## The push was a tag, aborting!"
exit
fi

echo "### git fetch $BRANCH ..."
git fetch origin $BRANCH
echo "### Branch: $BRANCH (ref: $GITHUB_REF )"
git checkout $BRANCH

echo "## Login into git..."
git config --global user.email "[email protected]"
git config --global user.name "MarvinJWendt"

echo "## Ignore workflow files (we may not touch them)"
git update-index --assume-unchanged .github/workflows/*

# Start release

git fetch --tags

echo "## Detecting current version of dops"
OLD_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "## $OLD_VERSION"

NEW_VERSION=$(cat pterm.go | grep "<---VERSION--->" | grep -oP "v\d*\.\d*\.\d*")

echo "## Version in commit detected: $NEW_VERSION!"

if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
echo "## Version did not change. Aborting!"
else
echo "## Version change detected!"

git tag "$NEW_VERSION"

echo "## Staging changes..."
git add .
echo "## Commiting files..."
git commit -m "ci: release new version" || true
echo "## Pushing to $BRANCH"
git push -u origin $BRANCH --tags
fi

0 comments on commit e65a1cc

Please sign in to comment.