diff --git a/.github/workflows/github-action-release.yml b/.github/workflows/github-action-release.yml index 5fbc586..105c279 100644 --- a/.github/workflows/github-action-release.yml +++ b/.github/workflows/github-action-release.yml @@ -1,8 +1,16 @@ +name: release-package on: push: branches: - release +env: + PROJECT_NAME: json + SCOPE: simatic-ax + ACTIONS_REPO: simatic-ax/actions + ACTIONS_LOCAL: ./actions + VERSIONING_TOOL_REPO: simatic-ax/simatic_versioning + jobs: versioning: name: "Bump the version of the package according to the conventional commit" @@ -13,29 +21,44 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: ${{ env.ACTIONS_REPO }} token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows + path: ./actions + - name: "Get the latest version of the package" + run: | + echo "@simatic-ax:registry=https://npm.pkg.github.com/" >> .npmrc + echo "//npm.pkg.github.com/:_authToken=${{ secrets.CI_KIT_TOKEN }}" >> .npmrc + echo "always-auth = true" >> .npmrc + cat .npmrc + echo "VERSION=$(npm show @${{ env.SCOPE }}/${{ env.PROJECT_NAME }} version --registry=https://npm.pkg.github.com --scope=${{ env.SCOPE }})" >> $GITHUB_ENV + echo $VERSION + - name: "Check contents of actions folder" + run: tree -d ./actions - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - name: "Get latest simatic-versioning executable" uses: dsaltares/fetch-gh-release-asset@master with: - repo: "simatic-ax/simatic_versioning" + repo: ${{ env.VERSIONING_TOOL_REPO }} file: "conventional-commit" token: ${{ secrets.CI_KIT_TOKEN }} - - name: "Bump version" + + - id: bump + name: "Bump version" run: | - ls -a - pwd + apax version ${{ env.VERSION }} sudo chmod +x ./conventional-commit - sudo ./conventional-commit \ - --commit-message "${{ github.event.head_commit.message }}" \ - --path . \ - --update \ + ./conventional-commit -c "${{ github.event.head_commit.message }}" -v "${{ env.VERSION }}" >> .version + cat .version + + - name: "Upload version" + uses: actions/upload-artifact@v3 + with: + name: version + path: .version build: name: "Build apax library" @@ -48,18 +71,23 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: ${{ env.ACTIONS_REPO }} token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows + path: ./actions + - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - - name: "Login to github registry" + + - name: "Login to the private repo" run: | - apax login --registry "https://npm.pkg.github.com" --password ${{ secrets.CI_KIT_TOKEN }} + apax login \ + --registry "https://npm.pkg.github.com" \ + --password ${{ secrets.CI_KIT_TOKEN }} + - name: "Build apax library" - uses: ./ax_ci_workflows/.github/actions/build-apax-package + uses: ./actions/.github/actions/apax-build with: library-directory: ${{ github.workspace }} apax-access-token: ${{ secrets.APAX_TOKEN }} @@ -81,19 +109,23 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: simatic-ax/actions token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows + path: ./actions - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - - name: "Login to github registry" + + - name: "Login to the private repo" run: | - apax login --registry "https://npm.pkg.github.com" --password ${{ secrets.CI_KIT_TOKEN }} + apax login \ + --registry "https://npm.pkg.github.com" \ + --password ${{ secrets.CI_KIT_TOKEN }} + - name: "Build apax library" - uses: ./ax_ci_workflows/.github/actions/build-apax-package + uses: ./actions/.github/actions/apax-test with: library-directory: ${{ github.workspace }} apax-access-token: ${{ secrets.APAX_TOKEN }} @@ -112,17 +144,15 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: simatic-ax/actions token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows + path: ./actions - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - - name: "Login to github registry" - run: | - apax login --registry "https://npm.pkg.github.com" --password ${{ secrets.CI_KIT_TOKEN }} + - name: "Download artifact" uses: actions/download-artifact@v3 with: @@ -134,8 +164,15 @@ jobs: --registry "https://npm.pkg.github.com" \ --password ${{ secrets.CI_KIT_TOKEN }} + - name: "Download artifact" + uses: actions/download-artifact@v3 + with: + name: version + - name: "Pack and publish the library" run: | + cat .version + apax version "$(cat .version)" apax pack 2>.package.err 1>.signature PACKAGE="$(grep -oP '(?<=\").+.apax\.tgz(?=\")' .package.err)" apax publish --package $PACKAGE --registry https://npm.pkg.github.com diff --git a/.github/workflows/github-action-test-apax.yml b/.github/workflows/github-action-test-apax.yml index 9c70c70..1814da0 100644 --- a/.github/workflows/github-action-test-apax.yml +++ b/.github/workflows/github-action-test-apax.yml @@ -1,6 +1,12 @@ name: test-apax on: push: + branches: + - '*' + - '!release' +env: + ACTIONS_REPO: simatic-ax/actions + VERSIONING_TOOL_REPO: simatic-ax/simatic_versioning jobs: build: @@ -14,22 +20,35 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: ${{ env.ACTIONS_REPO }} token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows + path: actions + + - name: "Check contents of actions folder" + run: tree -d ./actions - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - - name: "Login to github registry" + + - name: "Login to the private repo" run: | - apax login --registry "https://npm.pkg.github.com" --password ${{ secrets.CI_KIT_TOKEN }} + apax login \ + --registry "https://npm.pkg.github.com" \ + --password ${{ secrets.CI_KIT_TOKEN }} + - name: "Build apax library" - uses: ./ax_ci_workflows/.github/actions/build-apax-package + uses: ./actions/.github/actions/apax-build with: library-directory: ${{ github.workspace }} apax-access-token: ${{ secrets.APAX_TOKEN }} + - name: "Upload artifact" + uses: actions/upload-artifact@v3 + with: + name: library-artifact + path: bin/ + test: name: "Test apax library" runs-on: ubuntu-latest @@ -41,17 +60,21 @@ jobs: - name: "Clone repository for CI workflows" uses: actions/checkout@v3 with: - repository: kruegerfelix/ax_ci_workflows + repository: ${{ env.ACTIONS_REPO }} token: ${{ secrets.CI_KIT_TOKEN }} - path: ax_ci_workflows - + path: actions - name: "Install apax and dependencies" - uses: ./ax_ci_workflows/.github/actions/setup-apax-runner + uses: ./actions/.github/actions/setup-apax-runner with: apax-access-token: ${{ secrets.APAX_TOKEN }} - - name: "Build apax library" - uses: ./ax_ci_workflows/.github/actions/test-apax-package + - name: "Login to the private repo" + run: | + apax login \ + --registry "https://npm.pkg.github.com" \ + --password ${{ secrets.CI_KIT_TOKEN }} + + - name: "Install workspace dependencies and test" + uses: ./actions/.github/actions/apax-test with: - library-directory: ${{ github.workspace }} apax-access-token: ${{ secrets.APAX_TOKEN }}