-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (133 loc) · 3.99 KB
/
create-release.yml
File metadata and controls
150 lines (133 loc) · 3.99 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Create release
on:
workflow_dispatch:
inputs:
program:
description: Program
required: true
default: mpl-faucet
type: choice
options:
- mpl-faucet
bump:
description: Version bump
required: true
default: patch
type: choice
options:
- patch
- minor
- major
git_ref:
description: Commit hash or branch to create release
required: false
type: string
default: main
env:
CACHE: true
jobs:
build_programs:
name: Programs
uses: ./.github/workflows/build-programs.yml
secrets: inherit
with:
git_ref: ${{ inputs.git_ref }}
test_programs:
name: Programs
uses: ./.github/workflows/test-programs.yml
secrets: inherit
with:
program_matrix: '["mpl-${{ inputs.program }}"]'
git_ref: ${{ inputs.git_ref }}
test_js:
name: JS client
needs: build_programs
uses: ./.github/workflows/test-js-client.yml
secrets: inherit
with:
git_ref: ${{ inputs.git_ref }}
test_rust:
name: Rust client
needs: build_programs
uses: ./.github/workflows/test-rust-client.yml
secrets: inherit
with:
git_ref: ${{ inputs.git_ref }}
create_release:
name: Create program release
runs-on: ubuntu-latest
needs: [test_js, test_rust, test_programs]
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}
- name: Bump Program Version
run: |
git fetch --tags --all
VERSION=`git tag -l --sort -version:refname "release/${{ inputs.program }}@*" | head -n 1 | sed 's|release/${{ inputs.program }}@||'`
MAJOR=`echo ${VERSION} | cut -d. -f1`
MINOR=`echo ${VERSION} | cut -d. -f2`
PATCH=`echo ${VERSION} | cut -d. -f3`
if [ "${{ inputs.bump }}" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "${{ inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
PROGRAM_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo PROGRAM_VERSION="${PROGRAM_VERSION}" >> $GITHUB_ENV
- name: Sanitize Ref
id: sanitize
shell: bash
run: |
REF="${{ inputs.git_ref }}"
if [ -z "$REF" ]; then
REF="default"
fi
SANITIZED=${REF//\//-}
echo "sanitized=$SANITIZED" >> "$GITHUB_OUTPUT"
- name: Download Program Builds
uses: actions/download-artifact@v4
with:
name: program-builds-${{ steps.sanitize.outputs.sanitized }}
- name: Identify Program
run: |
echo PROGRAM_NAME="mpl_${{ inputs.program }}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release/${{ inputs.program }}@${{ env.PROGRAM_VERSION }}
release_name: ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
body: |
Release ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./programs/.bin/${{ env.PROGRAM_NAME }}_program.so
asset_name: ${{ env.PROGRAM_NAME }}_program.so
asset_content_type: application/octet-stream
# - name: Update latest tag
# uses: actions/github-script@v5
# with:
# script: |
# github.rest.git.createRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: 'refs/tags/release/${{ inputs.program }}@latest',
# sha: '${{ github.sha }}'
# });