-
Notifications
You must be signed in to change notification settings - Fork 43
135 lines (117 loc) 路 4.69 KB
/
cicd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# ci.yaml
# Surmagic
#
# Created by Muhammed Gurhan Yerlikaya on 20.02.2022.
# Copyright 漏 2022 https://github.com/gurhub/surmagic.
#
name: 馃摝 Publish
# Controls when the workflow will run
on:
# Triggers the workflow on push a new tag
push:
tags:
- 'v**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
GIT_USER_NAME: "gurhub"
GIT_USER_EMAIL: "gurhanyerlikaya@gmail.com"
jobs:
create-variables:
runs-on: ubuntu-latest
outputs:
TEST: ${{ steps.repo.outputs.TEST }}
SOURCE_NAME: ${{ steps.repo.outputs.SOURCE_NAME }}
BRANCH: ${{ steps.repo.outputs.BRANCH }}
TAG: ${{ steps.repo.outputs.TAG }}
VERSION: ${{ steps.repo.outputs.VERSION }}
TAG_WITHOUT_V: ${{ steps.repo.outputs.TAG_WITHOUT_V }}
PACKAGE_URL: ${{ steps.package.outputs.PACKAGE_URL }}
PACKAGE_SHA256: ${{ steps.shasum.outputs.PACKAGE_SHA256 }}
steps:
- id: repo
run: |
echo "::set-output name=TEST::hello"
echo "::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}"
echo "::set-output name=BRANCH::${GITHUB_REF#refs/heads/}"
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
echo "::set-output name=TAG::${GITHUB_REF#refs/tags/}"
echo "::set-output name=TAG_WITHOUT_V::$(sed 's|v||' <<< ${GITHUB_REF#refs/*/})"
- id: package
run: |
echo "::set-output name=PACKAGE_URL::https://github.com/gurhub/surmagic/archive/refs/tags/${{steps.repo.outputs.TAG}}.tar.gz"
- id: shasum
run: |
curl -L ${{steps.package.outputs.PACKAGE_URL}} --output ${{steps.repo.outputs.TAG}}.tar.gz
echo "::set-output name=PACKAGE_SHA256::$(sha256sum ${{steps.repo.outputs.TAG}}.tar.gz | cut -d ' ' -f 1)"
test_all:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: [create-variables]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: 馃洅 Checkout for Test
uses: actions/checkout@v3
with:
ref: master
# Runs a single command using the runners shell
- name: Loging Test Variables
run: |
#echo "TEST: ${{needs.create-variables.outputs.TEST}}"
#echo "SOURCE_NAME: ${{needs.create-variables.outputs.SOURCE_NAME}}"
echo "BRANCH: ${{needs.create-variables.outputs.BRANCH}}"
echo "TAG: ${{needs.create-variables.outputs.TAG}}"
echo "PACKAGE_URL: ${{needs.create-variables.outputs.PACKAGE_URL}}"
echo "PACKAGE_SHA256: ${{needs.create-variables.outputs.PACKAGE_SHA256}}"
# ---------------------------------
# Create Release Binary
# ---------------------------------
create-release-binary:
runs-on: macos-latest
steps:
- name: 馃洅 Checkout for the Create Release Binary
uses: actions/checkout@v3
with:
ref: master
- run: |
echo "馃П Swift Build"
cd surmagic
ls -lat
swift build -c release --arch arm64 --arch x86_64
lipo -info .build/apple/Products/Release/surmagic
echo "馃彈 Copy the Binary"
cp .build/apple/Products/Release/surmagic ../bin/
- run: echo "馃殮 Commit for Create Release Binary"
- run: git show-ref
- run: git add .
- run: git status
- run: git commit -m "Create Release Binary and copy under the /bin directory"
- run: git status
- run: git push origin master
# ---------------------------------
# Update Homebrew Formula
# ---------------------------------
update-homebrew-formula:
permissions: write-all
runs-on: ubuntu-latest
needs: [create-variables, create-release-binary]
steps:
- name: 馃洅 Checkout
uses: actions/checkout@v3
with:
repository: gurhub/homebrew-surmagic
ref: master
token: ${{ secrets.TOKEN }}
- run: sed -i 's|url.*|url "'${{needs.create-variables.outputs.PACKAGE_URL}}'"|' surmagic.rb
- run: sed -i 's|sha256.*|sha256 "'${{needs.create-variables.outputs.PACKAGE_SHA256}}'"|' surmagic.rb
- run: git config user.email "${{ env.GIT_USER_EMAIL }}"
- run: git config user.name "${{ env.GIT_USER_NAME }}"
- run: echo "馃殮 Commit for Update Homebrew Formula"
- run: git show-ref
- run: git add .
- run: git status
- run: git commit -m "Updated version ${{needs.create-variables.outputs.TAG}}"
- run: git status
- run: git push origin master
- run: echo "馃帀 Successfully published to the Homebrew"