This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 25
144 lines (127 loc) · 4.95 KB
/
bump-implementations.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
136
137
138
139
140
141
142
143
144
name: Bump Released Spec in SDKs Repos
# Parse the CI output status and make a markdown summary
# TODO:
# - make the pipeline ignore failures so devs dont ignore the CI checks
# - add a step to add a comment summary with the failures in the PR, so PRs can act accordingly
# - add a step to automate issue creation for each failure (or update existing one)
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag (must follow pattern vN.N.N)"
required: true
type: string
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- repo: tbdex-js
ci_file: integrity-check.yml
spec_path: tbdex
job_step: test-with-node;Run tests
# - repo: tbdex-swift
# ci_file: ci.yml
# spec_path: Tests/tbDEXTestVectors/tbdex-spec
# job_step: build-and-test;Run tests
# - repo: tbdex-kt
# ci_file: ci.yml
# spec_path: tbdex
# job_step: build-test-deploy-snapshot-ubuntu;Build, Test
# - repo: tbdex-rs
# ci_file: ci.yml
# spec_path: tbdex
# job_step: build-test-deploy-snapshot-ubuntu;Build, Test
outputs:
tbdex-js: ${{ steps.output.outputs.tbdex-js }}
tbdex-swift: ${{ steps.output.outputs.tbdex-swift }}
tbdex-kt: ${{ steps.output.outputs.tbdex-kt }}
tbdex-rs: ${{ steps.output.outputs.tbdex-rs }}
runs-on: ubuntu-latest
steps:
- name: Get workflow tag
id: get-tag
run: |
TAG=${{ github.event.inputs.tag || github.ref_name }}
echo "Processing tag: $TAG"
# Validate tag format
if ! [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Tag '$TAG' is not in the required format vN.N.N"
exit 1
fi
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
- name: Generate an access token to write to downstream repo
uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2
id: app-token
with:
app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }}
owner: TBD54566975
repositories: ${{ matrix.repo }}
- name: Checkout spec repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
repository: TBD54566975/${{ matrix.repo }}
ref: main
submodules: true
# persist-credentials: false
- name: Setup Spec values
id: spec-vals
run: |
echo "SPEC_REF=tbd-ci-cd-robot/spec-bump" >> $GITHUB_OUTPUT
- name: Update spec submodule in ${{ matrix.repo }}
id: bump
run: |
# initialize configs and vars
SPEC_REF=tbd-ci-cd-robot/spec-bump
TAG=${{ steps.get-tag.outputs.TAG }}
REPO_ROOT=$(pwd)
git config user.name "tbd-ci-cd-robot[bot]"
git config user.email "${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}+tbd-ci-cd-robot[bot]@users.noreply.github.com"
echo "Current directory: $(pwd)"
# check if $SPEC_REF exists
echo "Checking if $SPEC_REF exists..."
if git ls-remote --exit-code origin $SPEC_REF; then
echo "$SPEC_REF exists, checking out..."
git fetch origin $SPEC_REF
git checkout $SPEC_REF || { echo "Failed to checkout $SPEC_REF"; exit 1; }
else
echo "$SPEC_REF doesn't exist, creating new branch..."
git checkout -b $SPEC_REF || { echo "Failed to create new branch $SPEC_REF"; exit 1; }
fi
# bumps the spec submodule
echo "Bumping spec submodule to $TAG..."
cd ${{ matrix.spec_path }}
echo "Updating submodule..."
git submodule update --init --recursive
echo "Fetching tags..."
git fetch --all --tags
echo "Checking out $TAG..."
git checkout $TAG
# commit changes and push
echo "Checking changes to commit..."
cd $REPO_ROOT
# only commit if needed
if git status --porcelain | grep -q '^M'; then
git add .
git commit -m "Bump tbdex spec to $TAG"
git push origin $SPEC_REF
echo "Changes committed and pushed to $SPEC_REF"
echo "PUSHED=true" >> $GITHUB_OUTPUT
else
echo "No changes to commit"
fi
- name: Manage autobump PR with the Changes
if: ${{ steps.bump.outputs.PUSHED == 'true' }}
run: echo "Creating PR..."
# uses: peter-evans/create-pull-request@v5
# with:
# token: ${{ steps.app-token.outputs.token }}
# title: Bump tbdex spec to ${{ steps.get-tag.outputs.TAG }}
# body: Bumps the tbdex spec to ${{ steps.get-tag.outputs.TAG }}
# head: ${{ steps.spec-vals.outputs.SPEC_REF }}