From d8bce352b6dadf51f5e0a42eaeeb82fb3dbea41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Caetano?= Date: Tue, 1 Oct 2019 18:59:24 -0300 Subject: [PATCH] chore(CI): auto deploy on tags --- .github/workflows/deploy.yml | 19 ++++++++++++ HomebrewFormula/ios-simulator-gif.rb | 7 ++++- bin/ios-simulator-gif | 2 +- scripts/deploy | 43 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100755 scripts/deploy diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7bc3b9f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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}} \ No newline at end of file diff --git a/HomebrewFormula/ios-simulator-gif.rb b/HomebrewFormula/ios-simulator-gif.rb index bb3925f..7939076 100644 --- a/HomebrewFormula/ios-simulator-gif.rb +++ b/HomebrewFormula/ios-simulator-gif.rb @@ -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 diff --git a/bin/ios-simulator-gif b/bin/ios-simulator-gif index 9805cac..b6d647f 100755 --- a/bin/ios-simulator-gif +++ b/bin/ios-simulator-gif @@ -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" diff --git a/scripts/deploy b/scripts/deploy new file mode 100755 index 0000000..f8917b5 --- /dev/null +++ b/scripts/deploy @@ -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 "actions@github.com" +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 \ No newline at end of file