|
| 1 | +# Publish workflow for DaxLib.Sample package |
| 2 | +# |
| 3 | +# This workflow creates a branch in the upstream repository sql-bi/daxlib to |
| 4 | +# add a new version of the package. After execution, access the sql-bi/daxlib |
| 5 | +# repository and manually create a Pull Request from the newly created branch. |
| 6 | +# |
| 7 | +# TODO: |
| 8 | +# - Automate the PR creation |
| 9 | + |
| 10 | +name: publish-daxlib-sample |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + # Checkout the current repository |
| 23 | + - name: checkout source |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + repository: ${{ github.repository }} |
| 27 | + path: source-repo |
| 28 | + |
| 29 | + # Checkout the upstream repository sql-bi/daxlib |
| 30 | + - name: checkout upstream |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + repository: sql-bi/daxlib |
| 34 | + path: upstream-repo |
| 35 | + token: ${{ secrets.DAXLIB_TOKEN }} # Required to push changes |
| 36 | + |
| 37 | + # Configure Git |
| 38 | + - name: git config |
| 39 | + working-directory: upstream-repo |
| 40 | + run: | |
| 41 | + git config user.name "${{ github.actor }}" |
| 42 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 43 | +
|
| 44 | + # Extract package version from manifest |
| 45 | + - name: get package version |
| 46 | + id: get_package_version |
| 47 | + working-directory: source-repo |
| 48 | + run: | |
| 49 | + VERSION=$(jq -r '.version' src/manifest.daxlib) |
| 50 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 51 | + echo "Package version: $VERSION" |
| 52 | +
|
| 53 | + # Create the feature branch for the new version |
| 54 | + - name: create release branch |
| 55 | + working-directory: upstream-repo |
| 56 | + run: git checkout -b "daxlibsample/release-${{ steps.get_package_version.outputs.version }}" |
| 57 | + |
| 58 | + # Create the package folder for the new version |
| 59 | + - name: create package folder |
| 60 | + working-directory: upstream-repo |
| 61 | + run: mkdir -p "packages/d/daxlib.sample/${{ steps.get_package_version.outputs.version }}" |
| 62 | + |
| 63 | + # Copy package files to the new folder |
| 64 | + - name: copy package files |
| 65 | + run: cp -rv source-repo/src/* "upstream-repo/packages/d/daxlib.sample/${{ steps.get_package_version.outputs.version }}/" |
| 66 | + |
| 67 | + # Stage and commit changes |
| 68 | + - name: git commit changes |
| 69 | + working-directory: upstream-repo |
| 70 | + run: git add -A && git commit -m "Add package DaxLib.Sample version ${{ steps.get_package_version.outputs.version }}" |
| 71 | + |
| 72 | + # Push branch to upstream repository |
| 73 | + - name: git push upstream |
| 74 | + working-directory: upstream-repo |
| 75 | + run: git push origin "daxlibsample/release-${{ steps.get_package_version.outputs.version }}" |
| 76 | + |
0 commit comments