|
| 1 | +name: Publish to mason registry |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + create-tag: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + - name: Get version from Mason.toml |
| 12 | + id: version |
| 13 | + uses: mikefarah/yq@v4 |
| 14 | + with: |
| 15 | + cmd: yq .brick.version Mason.toml |
| 16 | + - name: Bump version and push tag |
| 17 | + id: create_tag |
| 18 | + uses: mathieudutour/github-tag-action@v6.2 |
| 19 | + with: |
| 20 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + custom_tag: ${{ steps.version.outputs.result }} |
| 22 | + tag_prefix: "v" |
| 23 | + create_annotated_tag: true |
| 24 | + push-to-mason-registry: |
| 25 | + needs: create-tag |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + path: source-repo |
| 31 | + - name: Get version from Mason.toml |
| 32 | + id: version |
| 33 | + uses: mikefarah/yq@v4 |
| 34 | + with: |
| 35 | + cmd: yq .brick.version source-repo/Mason.toml |
| 36 | + - name: Get package name |
| 37 | + id: package_name |
| 38 | + uses: mikefarah/yq@v4 |
| 39 | + with: |
| 40 | + cmd: yq .brick.name source-repo/Mason.toml |
| 41 | + - name: Checkout mason-registry fork |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + repository: chapelautomaton/mason-registry |
| 45 | + token: ${{ secrets.MASON_PUBLISH_TOKEN }} |
| 46 | + path: mason-registry |
| 47 | + - name: Create branch and add package |
| 48 | + run: | |
| 49 | + VERSION="${{ steps.version.outputs.result }}" |
| 50 | + PACKAGE_NAME="${{ steps.package_name.outputs.result }}" |
| 51 | + cd mason-registry |
| 52 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + git checkout -b "${PACKAGE_NAME}-${VERSION}" |
| 55 | + mkdir -p "Bricks/${PACKAGE_NAME}" |
| 56 | + cp ../source-repo/Mason.toml "Bricks/${PACKAGE_NAME}/${VERSION}.toml" |
| 57 | + git add . |
| 58 | + git commit -m "Add ${PACKAGE_NAME} ${VERSION}" |
| 59 | + - name: Push changes |
| 60 | + uses: ad-m/github-push-action@v1 |
| 61 | + with: |
| 62 | + github_token: ${{ secrets.MASON_PUBLISH_TOKEN }} |
| 63 | + repository: chapelautomaton/mason-registry |
| 64 | + branch: "${{ steps.package_name.outputs.result }}-${{ steps.version.outputs.result }}" |
| 65 | + directory: mason-registry |
| 66 | + - name: Create pull request |
| 67 | + run: > |
| 68 | + gh pr create |
| 69 | + --repo chapel-lang/mason-registry |
| 70 | + --head "chapelautomaton:${{ steps.package_name.outputs.result }}-${{ steps.version.outputs.result }}" |
| 71 | + --base master |
| 72 | + --title "Add ${{ steps.package_name.outputs.result }} ${{ steps.version.outputs.result }}" |
| 73 | + --body "Add ${{ steps.package_name.outputs.result }} version ${{ steps.version.outputs.result }} to the mason registry" |
| 74 | + env: |
| 75 | + GH_TOKEN: ${{ secrets.MASON_PUBLISH_TOKEN }} |
| 76 | + |
0 commit comments