Skip to content

Commit eac7570

Browse files
Jochum van der Ploegrenancaraujoalestiago
authored
ci: add publish workflow (#731)
Co-authored-by: Renan <[email protected]> Co-authored-by: Alejandro Santiago <[email protected]>
1 parent 053c3cf commit eac7570

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- '*-v*.*.*'
7+
8+
jobs:
9+
to_publish:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
pull-requests: read
14+
15+
outputs:
16+
package: ${{ steps.package.outputs.package }}
17+
brick: ${{ steps.brick.outputs.brick }}
18+
19+
steps:
20+
- name: 📚 Git Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: 📦 Finding a package to publish
24+
id: package
25+
run: |
26+
tag=${GITHUB_REF#refs/*/}
27+
package=$(echo $tag | sed -En "s/^(.*)-v(.*)/\1/p")
28+
if [[ -d "packages/$package" ]]; then
29+
echo "::set-output name=package::${package}"
30+
fi
31+
32+
- name: 🧱 Finding a brick to publish
33+
id: brick
34+
if: steps.package.outputs.action == ''
35+
run: |
36+
tag=${GITHUB_REF#refs/*/}
37+
brick=$(echo $tag | sed -En "s/^(.*)-v(.*)/\1/p")
38+
if [[ -d "bricks/$brick" ]]; then
39+
echo "::set-output name=brick::${brick}"
40+
fi
41+
42+
failed_to_find:
43+
needs: to_publish
44+
if: needs.to_publish.outputs.package == '' && needs.to_publish.outputs.brick == ''
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: 😢 No package or brick found to publish
49+
run: exit 1
50+
51+
publish_package:
52+
needs: to_publish
53+
if: needs.to_publish.outputs.package != ''
54+
55+
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_pub_publish.yml@v1
56+
with:
57+
working-directory: packages/${{ needs.to_publish.outputs.package }}
58+
pub_credentials: secrets.PUB_CREDENTIALS
59+
60+
publish_brick:
61+
needs: to_publish
62+
if: needs.to_publish.outputs.brick != ''
63+
64+
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/mason_publish.yml@v1
65+
with:
66+
working-directory: bricks/${{ needs.to_publish.outputs.brick }}
67+
mason_credentials: secrets.MASON_CREDENTIALS

0 commit comments

Comments
 (0)