Skip to content

Commit

Permalink
Merge pull request #199 from semaphoreci/nb_php_latest
Browse files Browse the repository at this point in the history
Create release process
  • Loading branch information
shiroyasha authored Dec 22, 2020
2 parents d7c04ea + b378930 commit 86d5d33
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .semaphore/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "v1.0"
name: Release
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: "Release"
run:
when: "branch = 'master'"
task:
secrets:
- name: sem-robot-ghtoken
jobs:
- name: Create and Upload assets
commands:
- checkout
- rm -rf toolbox
- ./release/create_release.sh
7 changes: 7 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,10 @@ blocks:
- ./tests/support/bats-core/install.sh /usr/local
- bats tests/cache.bats
- bats tests/libcheckout.bats
promotions:
- name: Release
pipeline_file: "release.yml"
auto_promote_on:
- result: passed
branch:
- "^refs/tags/v*"
1 change: 0 additions & 1 deletion artifacts

This file was deleted.

5 changes: 0 additions & 5 deletions install-toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -o pipefail
IFS=$'\n\t'

DIST=$(uname)
ARTIFACT_CLI_VERSION="v0.2.8"

case $DIST in
Darwin)
Expand Down Expand Up @@ -102,12 +101,8 @@ fi
#

echo "Installing the artifacts CLI"
echo "Using http://packages.semaphoreci.com/${ARTIFACT_CLI_VERSION}/artifact_${DIST}_x86_64.tar.gz"
install_cmd curl -s -L --retry 5 -o artifact.tar.gz http://packages.semaphoreci.com/${ARTIFACT_CLI_VERSION}/artifact_${DIST}_x86_64.tar.gz
install_cmd tar xzf artifact.tar.gz
install_cmd mv artifact $INSTALL_PATH/artifact
install_cmd chmod +x $INSTALL_PATH/artifact
install_cmd rm -f artifact.tar.gz LICENSE README.md
if [[ $? -eq 0 ]];then
echo "artifacts installed"
else
Expand Down
77 changes: 77 additions & 0 deletions release/create_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

set -euo pipefail

ARTIFACT_CLI_VERSION="v0.2.8"
ARTIFACT_CLI_URL="https://github.com/semaphoreci/artifact/releases/download/$ARTIFACT_CLI_VERSION"

mkdir /tmp/Linux/toolbox
mkdir /tmp/Darwin/toolbox

#
# Get artifact releases
#
curl -s -L --retry 5 $ARTIFACT_CLI_URL/artifact_Linux_x86_64.tar.gz -o /tmp/Linux/Linux.tar.gz
curl -s -L --retry 5 $ARTIFACT_CLI_URL/artifact_Darwin_x86_64.tar.gz -o /tmp/Darwin/Darwin.tar.gz

#
# Unpack artifacts
#
cd /tmp/Linux && tar -zxf Linux.tar.gz && mv artifact toolbox/ && cd -
cd /tmp/Darwin && tar -zxf Darwin.tar.gz && mv artifact toolbox/ && cd -

#
# Cp toolbox files, to not mess up workspace
#
cp $SEMAPHORE_PROJECT_DIR/* /tmp/Linux/toolbox
cp $SEMAPHORE_PROJECT_DIR/* /tmp/Darwin/toolbox

#
# Create linux release
#
cd /tmp/Linux
tar -cf linux.tar toolbox

echo "toolbox Linux content: "
tar --list --verbose --file=linux.tar

#
# Create darwin release
#
cd /tmp/Darwin
tar -cf darwin.tar toolbox

echo "toolbox Darwin content: "
tar --list --verbose --file=darwin.tar

#
# Upload created release files to GitHub
#
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/semaphoreci/toolbox/releases \
-d '{"tag_name":"'$SEMAPHORE_GIT_TAG_NAME'"}'

release_id=$(curl --silent https://api.github.com/repos/semaphoreci/toolbox/releases/tags/$SEMAPHORE_GIT_TAG_NAME | grep -m1 'id' | awk '{print $2}' | tr -d ',' )

curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: $(file -b --mime-type /tmp/Linux/linux.tar)" \
--data-binary @/tmp/Linux/linux.tar \
"https://uploads.github.com/repos/semaphoreci/toolbox/releases/$release_id/assets?name=linux.tar"

echo "linux.tar uploaded"

curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: $(file -b --mime-type /tmp/Darwin/darwin.tar)" \
--data-binary @/tmp/Darwin/darwin.tar \
"https://uploads.github.com/repos/semaphoreci/toolbox/releases/$release_id/assets?name=darwin.tar"

echo "darwin.tar uploaded"

0 comments on commit 86d5d33

Please sign in to comment.