Yuki Takei 9 лет назад
Родитель
Сommit
c483283c44
2 измененных файлов с 38 добавлено и 35 удалено
  1. 9 0
      bin/wercker/init-git.sh
  2. 29 35
      wercker.yml

+ 9 - 0
bin/wercker/init-git.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+git config --global user.name "wercker"
+git config --global user.email "info@weseek.co.jp"
+
+# reconfigure origin
+GITHUB_ORIGIN=https://yuki-takei:$GITHUB_TOKEN@$WERCKER_GIT_DOMAIN/$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY.git
+git remote rm origin
+git remote add origin $GITHUB_ORIGIN

+ 29 - 35
wercker.yml

@@ -72,57 +72,51 @@ build-dev:
         npm run build:dev
 
 
-prepare-to-release: # would be run on release branch
+release: # would be run on release branch
   steps:
     - script:
       name: bump version
       code: |
-        git config --global user.name "wercker"
-        git config --global user.email "info@weseek.co.jp"
+        sh ./bin/wercker/init-git.sh
         # npm version to bump version
         npm version patch
-        # export $RELEASE_VERSION
-        export RELEASE_VERSION=`npm run version --silent`
-        echo "export RELEASE_VERSION=$RELEASE_VERSION"
+        # get version
+        RELEASE_VERSION=`npm run version --silent`
+        echo "RELEASE_VERSION=$RELEASE_VERSION"
 
     - script:
-      name: push to github to create new branch
+      name: commit and push
       code: |
-        # reconfigure origin
-        GITHUB_ORIGIN=https://yuki-takei:$GITHUB_TOKEN@$WERCKER_GIT_DOMAIN/$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY.git
-        git remote set-url origin $GITHUB_ORIGIN
-        git checkout -B tmp/release-$RELEASE_VERSION
-        git push -u origin HEAD:tmp/release-$RELEASE_VERSION
-
-
-release-to-github: # would be run on temporary release branch
-  steps:
-    - script:
-      name: get version
-      code: |
-        export RELEASE_VERSION=`npm run version --silent`
-        echo "export RELEASE_VERSION=$RELEASE_VERSION"
+        TMP_RELEASE_BRANCH=tmp/release-$RELEASE_VERSION
+        git checkout -B $TMP_RELEASE_BRANCH
+        git push -u origin HEAD:$TMP_RELEASE_BRANCH
+        TARGET_COMMITISH=`git rev-parse HEAD`
 
     - github-create-release:
       token: $GITHUB_TOKEN
       tag: v$RELEASE_VERSION
+      target-commitish: $TARGET_COMMITISH
 
     - script:
       name: remove temporary release branch
       code: |
-        git config --global user.name "wercker"
-        git config --global user.email "info@weseek.co.jp"
-        # reconfigure origin
-        GITHUB_ORIGIN=https://yuki-takei:$GITHUB_TOKEN@$WERCKER_GIT_DOMAIN/$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY.git
-        git remote rm origin
-        git remote add origin $GITHUB_ORIGIN
-        # remove branch
-        git push --delete origin $WERCKER_GIT_BRANCH
-
-
-# the pipeline that do nothing
-#  this is needed while wercker can't detect specified branch pushed
-empty:
+        git push --delete origin $TMP_RELEASE_BRANCH
+
+
+trigger-crowi-plus-docker:
   steps:
     - script:
-      code: echo "this is $WERCKER_GIT_BRANCH branch"
+      name: trigger crowi-plus-docker release pipeline
+      code: >
+        curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $WERCKER_TOKEN" https://app.wercker.com/api/v3/runs -d
+        '{
+          "pipelineId": "$TARGET_PIPELINE_ID",
+          "sourceRunId": "$WERCKER_RUN_ID",
+          "branch": "release",
+          "envVars": [
+            {
+              "key": "RELEASE_VERSION",
+              "value": "$RELEASE_VERSION"
+            }
+          ]
+        }'