Skip to content

Commit

Permalink
chore(CI): auto deploy on tags
Browse files Browse the repository at this point in the history
  • Loading branch information
fjcaetano committed Oct 2, 2019
1 parent 20f6fae commit d8bce35
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: update package version
run: |
scripts/deploy
env:
CI: true
ACCESS_TOKEN: ${{secrets.PUBLISH_TOKEN}}
7 changes: 6 additions & 1 deletion HomebrewFormula/ios-simulator-gif.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class IosSimulatorGif < Formula
version "1.1.0"
desc "Record a gif from your iOS simulator in a jiffy"
homepage "https://github.com/fjcaetano/ios-simulator-gif"
url "https://github.com/fjcaetano/ios-simulator-gif/archive/1.1.0.tar.gz"
url "https://codeload.github.com/fjcaetano/ios-simulator-gif/tar.gz/#{version}"
sha256 "79cba993e64e115e69b160553bbd2cd9b4a9c09cf93efb9b1ada5e8e7958bc72"

depends_on "ffmpeg"
depends_on "gnu-sed"

def install
inreplace "bin/ios-simulator-gif" do |s|
s.gsub! /PKG_VERSION=.*/, "PKG_VERSION='#{version}'"
end

bin.install "bin/ios-simulator-gif"
end

Expand Down
2 changes: 1 addition & 1 deletion bin/ios-simulator-gif
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Records iOS simulator screen and saves as a gif to simulator.gif
# A new file name may be passed as argument

PKG_VERSION="1.1.0"
PKG_VERSION="${ENV_VERSION}"
RED="\033[1;31m"
GREEN="\033[1;32m"
CLEAR="\033[0m"
Expand Down
43 changes: 43 additions & 0 deletions scripts/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

GIT_TAG="$(echo "${GITHUB_REF}" | sed 's;refs/tags/;;')"
echo "Bumping version to ${GIT_TAG}"

# Extract data
URL="https://codeload.github.com/${GITHUB_REPOSITORY}/tar.gz/${GIT_TAG}"

echo "Downloading package..."

curl -sf "${URL}" > package.tar.gz
if [[ $? -ne 0 ]]; then
rm package.tar.gz
echo 'curl failed';
exit 1;
fi

DIGEST="$(openssl sha256 package.tar.gz | sed 's/^.* //')"
rm package.tar.gz

echo -e "SHA256: ${DIGEST}\n"
echo -e "Updating files...\n"

# Update files
sed -i "s/version \".*/version \"${GIT_TAG}\"/" HomebrewFormula/ios-simulator-gif.rb
sed -i "s/sha256.*/sha256 \"${DIGEST}\"/" HomebrewFormula/ios-simulator-gif.rb

echo "Changed files:"
echo -e "$(git diff --name-only)\n"

# Git config
git config user.email "[email protected]"
git config user.name "Github Actions"

echo "Committing changes..."

git add bin/ios-simulator-gif HomebrewFormula/ios-simulator-gif.rb
git commit -m "chore(Deploy): version ${GIT_TAG}" --quiet --no-verify

# Push
echo "Pushing commit..."
REPO_PATH="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${REPO_PATH}" HEAD:master

0 comments on commit d8bce35

Please sign in to comment.