diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..00856c8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +--- +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + paths: + - src/** + - Dockerfile + - package.json + - package-lock.json + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: read + +jobs: + code: + uses: ./.github/workflows/test_package.yml + image: + needs: code + uses: ./.github/workflows/test_image.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 04edc4a..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,71 +0,0 @@ ---- -name: Pull request build - -on: - pull_request: - branches: - - master - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - pull-requests: read - -jobs: - code: - strategy: - matrix: - node: ['20', 'latest'] - os: [ubuntu-latest, macos-latest] - runs-on: ${{ matrix.os }} - name: "Test project { os: ${{ matrix.os }}, node: ${{ matrix.node }} }" - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Install node ${{ matrix.node }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: npm - - # required for testing - - name: Configure git - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - - name: Install project modules - run: npm ci - - - name: Lint source files - run: npm run lint - - - name: Run unit tests - run: npm test - - image: - runs-on: ubuntu-latest - needs: [code] - name: Test container image - env: - TESTING_TAG: tomerfi/version-bumper:testing - steps: - - name: Setup docker buildx - uses: docker/setup-buildx-action@v3 - - - name: Build image - uses: docker/build-push-action@v5 - with: - tags: ${{ env.TESTING_TAG }} - cache-from: type=gha - cache-to: type=gha,mode=max - load: true - - - name: Test image run - run: | - pattern='^version-bumper ([0-9]\.){2}[0-9](.+)?$' - sut=$(docker run --rm ${{ env.TESTING_TAG }} -v) - [[ $sut =~ $pattern ]] || exit 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 828bf16..4aae167 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,14 +36,6 @@ jobs: git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - - name: Setup qemu - uses: docker/setup-qemu-action@v3 - with: - platforms: ${{ vars.PLATFORMS }} - - - name: Setup docker buildx - uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -110,7 +102,6 @@ jobs: with: context: . push: ${{ github.event.inputs.dry-run != 'true' }} - platforms: ${{ vars.PLATFORMS }} tags: | tomerfi/version-bumper:latest tomerfi/version-bumper:${{ steps.bump.outputs.version }} diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml deleted file mode 100644 index 51f3ef0..0000000 --- a/.github/workflows/stage.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- -name: Stage - -on: - workflow_dispatch: - push: - branches: - - master - paths: - - src/** - - Dockerfile - - package.json - - package-lock.json - -concurrency: - group: stage-project - cancel-in-progress: true - -jobs: - code: - runs-on: ubuntu-latest - name: Test project - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Install node 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - # required for testing - - name: Configure git - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - - name: Install project modules - run: npm ci - - - name: Lint source files - run: npm run lint - - - name: Run unit tests - run: npm test - - image: - runs-on: ubuntu-latest - needs: [code] - name: Build image - steps: - - name: Setup docker buildx - uses: docker/setup-buildx-action@v3 - - - name: Build image - uses: docker/build-push-action@v5 - with: - tags: tomerfi/version-bumper:staging - cache-from: type=gha - cache-to: type=gha,mode=max - load: true - diff --git a/.github/workflows/test_image.yml b/.github/workflows/test_image.yml new file mode 100644 index 0000000..719a91d --- /dev/null +++ b/.github/workflows/test_image.yml @@ -0,0 +1,26 @@ +--- +name: Build and Test Image + +on: + workflow_call: + workflow_dispatch: + +jobs: + image: + runs-on: ubuntu-latest + name: Test container image + env: + TESTING_TAG: tomerfi/version-bumper:testing + steps: + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 + with: + tags: ${{ env.TESTING_TAG }} + cache-from: type=gha + cache-to: type=gha,mode=max + load: true + - name: Test image run + run: | + pattern='^@tomerfi/version-bumper ([0-9]\.){2}[0-9](.+)?$' + sut=$(docker run --rm ${{ env.TESTING_TAG }} -v) + [[ $sut =~ $pattern ]] || exit 1 diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml new file mode 100644 index 0000000..3580291 --- /dev/null +++ b/.github/workflows/test_package.yml @@ -0,0 +1,29 @@ +--- +name: Test and Build Package + +on: + workflow_call: + workflow_dispatch: + +jobs: + test: + strategy: + matrix: + node: ['20', 'latest'] + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + name: "Test project { os: ${{ matrix.os }}, node: ${{ matrix.node }} }" + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + cache: npm + # required for testing + - run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + - run: npm ci + - run: npm run lint + - run: npm test +