|
13 | 13 | type: string |
14 | 14 | required: true |
15 | 15 |
|
| 16 | +permissions: {} |
| 17 | + |
16 | 18 | jobs: |
17 | 19 | validate-version: |
18 | 20 | runs-on: ubuntu-latest |
| 21 | + permissions: {} |
19 | 22 | outputs: |
20 | | - validated-dbt-package-version: ${{ steps.validate-dbt-package-input.outputs.dbt-package-validation }} |
| 23 | + version: ${{ steps.validate.outputs.version }} |
21 | 24 | steps: |
22 | | - - name: validate dbt package version |
23 | | - id: validate-dbt-package-input |
24 | | - run: echo "dbt-package-validation=$(echo ${{ inputs.dbt-package-version }} | sed -n '/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/p')" >> $GITHUB_OUTPUT |
25 | | - - name: echo versions |
| 25 | + - name: Validate dbt package version |
| 26 | + id: validate |
| 27 | + env: |
| 28 | + VERSION: ${{ inputs.dbt-package-version }} |
26 | 29 | run: | |
27 | | - echo "dbt package version: ${{ steps.validate-dbt-package-input.outputs.dbt-package-validation }}" |
28 | | - - name: fail on invalid input |
29 | | - if: ${{ steps.validate-dbt-package-input.outputs.dbt-package-validation == '' }} |
30 | | - uses: actions/github-script@v8 |
31 | | - with: |
32 | | - script: | |
33 | | - core.setFailed("Invalid version input - ${{ inputs.dbt-package-version }}") |
| 30 | + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 31 | + echo "::error::Invalid version: $VERSION" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
34 | 35 |
|
35 | 36 | bump-version: |
36 | 37 | needs: validate-version |
37 | 38 | runs-on: ubuntu-latest |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + env: |
| 42 | + VERSION: ${{ needs.validate-version.outputs.version }} |
38 | 43 | steps: |
39 | 44 | - name: Checkout code |
40 | 45 | uses: actions/checkout@v6 |
41 | 46 | - name: Create release branch |
42 | | - run: git checkout -b release/${{ inputs.dbt-package-version }} |
| 47 | + run: git checkout -b "release/$VERSION" |
43 | 48 | - name: Initial config |
44 | 49 | run: | |
45 | 50 | git config user.name "GitHub Actions" |
46 | 51 | git config user.email noreply@github.com |
47 | 52 | - name: Bump package version |
48 | 53 | run: | |
49 | | - sed -i 's/version: "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"$/version: "${{ inputs.dbt-package-version }}"/' ./dbt_project.yml |
| 54 | + sed -i 's/version: "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"$/version: "'"$VERSION"'"/' ./dbt_project.yml |
50 | 55 | - name: Bump readme package version |
51 | 56 | run: | |
52 | | - sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ inputs.dbt-package-version }}/' ./README.md |
| 57 | + sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: '"$VERSION"'/' ./README.md |
53 | 58 | - name: Commit changes |
54 | | - run: git commit -am "release ${{ inputs.dbt-package-version }}" |
| 59 | + run: git commit -am "release $VERSION" |
55 | 60 | - name: Push code |
56 | | - run: git push origin release/${{ inputs.dbt-package-version }} |
| 61 | + run: git push origin "release/$VERSION" |
57 | 62 |
|
58 | 63 | create-pr: |
59 | | - needs: bump-version |
| 64 | + needs: [validate-version, bump-version] |
60 | 65 | runs-on: ubuntu-latest |
| 66 | + permissions: |
| 67 | + contents: read |
| 68 | + pull-requests: write |
61 | 69 | steps: |
62 | 70 | - uses: actions/checkout@v6 |
63 | 71 | - name: create pull request |
64 | | - uses: repo-sync/pull-request@v2 |
| 72 | + uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # v2 |
65 | 73 | with: |
66 | | - source_branch: "release/${{ inputs.dbt-package-version }}" |
| 74 | + source_branch: "release/${{ needs.validate-version.outputs.version }}" |
67 | 75 | destination_branch: "master" |
68 | | - pr_title: "release/${{ inputs.dbt-package-version }}" |
| 76 | + pr_title: "release/${{ needs.validate-version.outputs.version }}" |
69 | 77 | pr_body: "Open automatically using bump version workflow" |
70 | 78 | github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments