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