-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (90 loc) · 3.51 KB
/
publish-artifact-bundle.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
name: Publish Artifact Bundle
on:
workflow_call:
inputs:
binary_name:
required: true
type: string
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string
# Enables manually running this workflow from the Actions tab
workflow_dispatch:
inputs:
binary_name:
required: true
type: string
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string
jobs:
publish:
name: Publish Artifact Bundle
runs-on: macOS-13
env:
PLUGIN_VERSION: ${{ inputs.binary_version }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ inputs.binary_name }}
- name: Get latest binaries
run: |
gh release download ${{ inputs.binary_version }} \
-R "${{ inputs.binary_repo }}" \
-p '*MacOS*64' \
-p '*Linux*64' \
-p '*Windows*64.exe' \
-p '*.deb' \
-p '*.rpm' \
-D '${{ inputs.binary_name }}/Resources/template.artifactbundle'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update GitHub Env Vars
run: |
# The example binary includes a leading 'v' in the release version number. We drop it on the next line.
echo "PLUGIN_VERSION=$(echo $PLUGIN_VERSION | cut -c2-)" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ inputs.binary_name }}.artifactbundle.zip" >> $GITHUB_ENV
echo "ARTIFACT_PATH=${{ inputs.binary_name }}/Resources/template.artifactbundle" >> $GITHUB_ENV
- name: Set info.json version
run: |
sed -i '' "s/<VERSION>/${{ env.PLUGIN_VERSION }}/g" ${{ env.ARTIFACT_PATH }}/info.json
sed -i '' "s/<TEMPLATE>/${{ inputs.binary_name }}/g" ${{ env.ARTIFACT_PATH }}/info.json
- name: Add executable permissions
run: |
# The example binaries for MacOS need the executable permission added.
chmod +x "${{ env.ARTIFACT_PATH }}/${{ inputs.binary_name }}_${{ env.PLUGIN_VERSION }}_MacOS_arm64"
chmod +x "${{ env.ARTIFACT_PATH }}/${{ inputs.binary_name }}_${{ env.PLUGIN_VERSION }}_MacOS_x86_64"
- name: Zip Artifact Bundle
run: |
zip -9 -r ${{ env.ARTIFACT_NAME }} ${{ env.ARTIFACT_PATH }}
- name: Reset Git Repo
run: |
(cd ${{ inputs.binary_name }} && git reset --hard)
- name: Update Package.swift
run: |
sed -i '' 's/checksum: ".*"/checksum: "${{ hashFiles( env.ARTIFACT_NAME ) }}"/g' ${{ inputs.binary_name }}/Package.swift
sed -i '' -E "s/\/[0-9]+\.[0-9]+\.[0-9]+\//\/1.4.10\//" ${{ inputs.binary_name }}/Package.swift
- name: Push Changes to GitHub
run: |
(cd ${{ inputs.binary_name }} && git commit -am "Updating ${{ inputs.binary_name }} to ${{ env.PLUGIN_VERSION }}" && git push origin)
- name: Create GitHub Release
run: |
echo $(cd ${{ inputs.binary_name }} && git rev-parse HEAD)
gh release create ${{ env.PLUGIN_VERSION }} \
-R ${{ inputs.plugin_repo }} \
--target $(cd ${{ inputs.binary_name }} && git rev-parse HEAD) \
${{ env.ARTIFACT_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}