diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 584a9a5..9c67c61 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -5,7 +5,7 @@ on: inputs: projects: required: true - description: "Comma-separated list of projects to build" + description: 'Comma-separated list of projects to build' type: string jobs: @@ -35,4 +35,4 @@ jobs: push: false cache-from: type=gha cache-to: type=gha,mode=max - file: ${{ matrix.project }}/Dockerfile \ No newline at end of file + file: ${{ matrix.project }}/Dockerfile diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..f807cb7 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,113 @@ +name: Docker Release + +on: + workflow_call: + inputs: + projects: + required: true + description: 'Comma-separated list of projects to release' + type: string + version: + required: true + description: 'Version of the Docker release' + type: string + docker-registry: + required: true + description: 'Docker registry to push the Docker image to' + type: string + github-registry: + required: false + description: 'Whether to push the image to the GitHub registry' + type: string + env-file: + required: false + description: 'Contents of the ENV file to use during building, should only be used as an exception.' + type: string + docker-paths: + required: true + description: 'Comma-separated list of Docker paths corresponding to each project' + type: string + secrets: + REGISTRY_USERNAME: + required: true + REGISTRY_PASSWORD: + required: true + +jobs: + release: + runs-on: ubuntu-latest + if: ${{ inputs.version != '' }} + permissions: + packages: write + container: + image: docker:dind + strategy: + matrix: + project: ${{ fromJson(inputs.projects) }} + docker-path: ${{ fromJson(inputs.docker-paths) }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up environment + if: ${{ inputs.env-file != '' }} + env: + ENV_FILE: ${{ inputs.env-file }} + run: | + echo "${ENV_FILE}" > ${{ matrix.project }}/.env + + - name: Extract Image Name + id: extract + run: | + input="${{ matrix.docker-path }}" + result="${input#*/}" + echo "{name}={part}" >> $result + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Registry (GitHub) + if: ${{ inputs.github-registry == 'true' }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push Docker Image (GitHub) + if: ${{ inputs.github-registry == 'true' }} + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: | + ghcr.io/gewis/${{ steps.extract.outputs.part }}:latest + ghcr.io/gewis/${{ steps.extract.outputs.part }}:${{inputs.version}} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ${{ matrix.project }}/Dockerfile + + - name: Login to Registry (Custom) + uses: docker/login-action@v3 + with: + registry: ${{ inputs.docker-registry }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build and Push Docker Image (Custom) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: | + ${{ inputs.docker-registry }}/${{ matrix.docker-path }}:latest + ${{ inputs.docker-registry }}/${{ matrix.docker-path }}:${{ inputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ${{ matrix.project }}/Dockerfile diff --git a/.github/workflows/lint-and-build-npm.yml b/.github/workflows/lint-and-build-npm.yml new file mode 100644 index 0000000..edc92c9 --- /dev/null +++ b/.github/workflows/lint-and-build-npm.yml @@ -0,0 +1,96 @@ +name: TypeScript Lint and Build with NPM + +on: + workflow_call: + inputs: + working-directory: + required: false + type: string + default: '.' + node-version: + required: false + type: string + default: '20.x' + artifact-name: + required: false + type: string + description: 'Name of artifact to use' + artifact-path: + required: false + type: string + description: 'Path to place artifact' + prepare-command: + required: false + type: string + description: 'Command to run directly after checkout.' + cleanup-command: + required: false + type: string + description: 'Command to run after the workflow (even if failed).' + lint: + type: boolean + description: 'Run the lint step.' + default: true + format: + type: boolean + description: 'Run the format step.' + default: false + test: + type: boolean + description: 'Run the test step.' + default: false + build: + type: boolean + description: 'Run the build step.' + default: true + +jobs: + npm-steps: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: ${{ inputs.artifact-path }} + if: ${{ inputs.artifact-name != '' }} + + - name: Prepare + run: ${{ inputs.prepare-command }} + if: ${{ inputs.prepare-command != '' }} + + - name: Set Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Install dependencies + working-directory: ${{ inputs.working-directory }} + run: npm install + + - name: Lint the project + working-directory: ${{ inputs.working-directory }} + run: npm run lint + if: ${{ inputs.lint }} + + - name: Format the project + working-directory: ${{ inputs.working-directory }} + run: npm run format + if: ${{ inputs.format }} + + - name: Test the project + working-directory: ${{ inputs.working-directory }} + run: npm run test + if: ${{ inputs.test }} + + - name: Build the project + working-directory: ${{ inputs.working-directory }} + run: npm run build + if: ${{ inputs.build }} + + - name: Cleanup + run: ${{ inputs.cleanup-command }} + if: ${{ inputs.cleanup-command != '' && always() }} diff --git a/.github/workflows/lint-and-build-yarn.yml b/.github/workflows/lint-and-build-yarn.yml new file mode 100644 index 0000000..9fac0e5 --- /dev/null +++ b/.github/workflows/lint-and-build-yarn.yml @@ -0,0 +1,106 @@ +name: TypeScript Lint and Build with Yarn + +on: + workflow_call: + inputs: + working-directory: + required: false + type: string + default: '.' + node-version: + required: false + type: string + default: '20.x' + artifact-name: + required: false + type: string + description: 'Name of artifact to use' + artifact-path: + required: false + type: string + description: 'Path to place artifact' + prepare-command: + required: false + type: string + description: 'Command to run directly after checkout.' + cleanup-command: + required: false + type: string + description: 'Command to run after the workflow (even if failed).' + lint: + type: boolean + description: 'Run the lint step.' + default: true + format: + type: boolean + description: 'Run the format step.' + default: false + test: + type: boolean + description: 'Run the test step.' + default: false + build: + type: boolean + description: 'Run the build step.' + default: true + +jobs: + yarn-steps: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: ${{ inputs.artifact-path }} + if: ${{ inputs.artifact-name != '' }} + + - name: Prepare + run: ${{ inputs.prepare-command }} + if: ${{ inputs.prepare-command != '' }} + + - name: Set Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Install dependencies + uses: borales/actions-yarn@v4 + with: + cmd: install + dir: ${{ inputs.working-directory }} + + - name: Lint the project + uses: borales/actions-yarn@v4 + with: + cmd: lint + dir: ${{ inputs.working-directory }} + if: ${{ inputs.lint }} + + - name: Format the project + uses: borales/actions-yarn@v4 + with: + cmd: format + dir: ${{ inputs.working-directory }} + if: ${{ inputs.format }} + + - name: Test the project + uses: borales/actions-yarn@v4 + with: + cmd: test + dir: ${{ inputs.working-directory }} + if: ${{ inputs.test }} + + - name: Build the project + uses: borales/actions-yarn@v4 + with: + cmd: build + dir: ${{ inputs.working-directory }} + if: ${{ inputs.build }} + + - name: Cleanup + run: ${{ inputs.cleanup-command }} + if: ${{ inputs.cleanup-command != '' && always() }} diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml new file mode 100644 index 0000000..3396bc5 --- /dev/null +++ b/.github/workflows/npm-release.yml @@ -0,0 +1,73 @@ +name: NPM Release + +on: + workflow_call: + inputs: + node-version: + required: false + type: string + description: 'The node version required for the project' + default: '20.x' + version: + required: true + description: 'Version of the package(s)' + type: string + lerna: + required: false + description: 'Whether project is a lerna project' + type: string + +jobs: + publish-npm: + runs-on: ubuntu-latest + if: ${{ inputs.lerna != 'true' && inputs.version != '' }} + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + registry-url: 'https://npm.pkg.github.com' + scope: '@gewis' + + - name: Publish + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-npm-lerna: + runs-on: ubuntu-latest + if: ${{ inputs.lerna == 'true' && inputs.version != '' }} + permissions: + packages: write + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Git Config + run: git config user.email 'github-actions@github.com' && git config user.name 'github-actions' + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + registry-url: 'https://npm.pkg.github.com' + scope: '@gewis' + + - name: Lerna Publish + run: npx --yes lerna version ${{ inputs.version }} --amend --yes && npx lerna publish from-git --yes + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Tags + run: git push --force-with-lease --follow-tags diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml deleted file mode 100644 index c1fd9b8..0000000 --- a/.github/workflows/semantic-release.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Semantic Release - -on: - workflow_call: - inputs: - projects: - required: true - description: "Comma-separated list of projects to release" - type: string - docker_registry: - required: true - type: string - env_file: - required: false - description: "Contents of the ENV file to use during building, should only be used as an exception." - type: string - docker_paths: - required: true - description: "Comma-separated list of Docker paths corresponding to each project" - type: string - secrets: - REGISTRY_USERNAME: - required: true - REGISTRY_PASSWORD: - required: true - -jobs: - versioning: - uses: ./.github/workflows/versioning.yml - - release: - runs-on: ubuntu-latest - needs: versioning - if: ${{ needs.versioning.outputs.next_version != '' }} - container: - image: docker:dind - strategy: - matrix: - project: ${{ fromJson(inputs.projects) }} - docker_path: ${{ fromJson(inputs.docker_paths) }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up environment - if: ${{ inputs.env_file != '' }} - env: - ENV_FILE: ${{ inputs.env_file }} - run: | - echo "${ENV_FILE}" > ${{ matrix.project }}/.env - - - name: Get Docker meta (for tags) - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ${{ inputs.docker_registry }}/${{ matrix.docker_path }} - tags: | - ${{ needs.versioning.outputs.next_version }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ inputs.docker_registry }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - file: ${{ matrix.project }}/Dockerfile diff --git a/.github/workflows/typescript-lint-and-build.yml b/.github/workflows/typescript-lint-and-build.yml deleted file mode 100644 index f5f5306..0000000 --- a/.github/workflows/typescript-lint-and-build.yml +++ /dev/null @@ -1,172 +0,0 @@ -name: Build and Lint TypeScript Project - -on: - workflow_call: - inputs: - working-directory: - required: false - description: "The directory where the TypeScript project is located." - type: string - default: "." - node-version: - required: false - type: string - description: "The node version required for the TypeScript project." - default: "20.x" - # options: - # - 22.x - # - 20.x - # - 18.x - package-manager: - required: false - type: string - description: "The package manager to use for the TypeScript project." - default: "npm" - # options: - # - yarn - # - npm - artifact-name: - required: false - type: string - description: "Name of artifact to use" - artifact-path: - required: false - type: string - description: "Path to place artifact" - prepare-command: - required: false - type: string - description: "Command to run directly after checkout." - cleanup-command: - required: false - type: string - description: "Command to run after the workflow (even if failed)." - lint: - type: boolean - description: "Use the lint step." - default: true - format: - type: boolean - description: "Use the format step." - default: false - test: - type: boolean - description: "Use the test step." - default: false - build: - type: boolean - description: "Use the build step." - default: true - -jobs: - build-and-lint-yarn: - if: ${{ inputs.package-manager == 'yarn' }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Artifact - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.artifact-name }} - path: ${{ inputs.artifact-path }} - if: ${{ inputs.artifact-name != '' }} - - - name: Prepare - run: ${{ inputs.prepare-command }} - if: ${{ inputs.prepare-command != '' }} - - - name: Set Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - - name: Install dependencies - uses: borales/actions-yarn@v4 - with: - cmd: install - dir: ${{ inputs.working-directory }} - - - name: Lint the project - uses: borales/actions-yarn@v4 - with: - cmd: lint - dir: ${{ inputs.working-directory }} - if: ${{ inputs.lint }} - - - name: Format the project - uses: borales/actions-yarn@v4 - with: - cmd: format - dir: ${{ inputs.working-directory }} - if: ${{ inputs.format }} - - - name: Test the project - uses: borales/actions-yarn@v4 - with: - cmd: test - dir: ${{ inputs.working-directory }} - if: ${{ inputs.test }} - - - name: Build the project - uses: borales/actions-yarn@v4 - with: - cmd: build - dir: ${{ inputs.working-directory }} - if: ${{ inputs.build }} - - - name: Cleanup - run: ${{ inputs.cleanup-command }} - if: ${{ inputs.cleanup-command != '' && always() }} - - build-and-lint-npm: - if: ${{ inputs.package-manager == 'npm' }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Artifact - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.artifact-name }} - path: ${{ inputs.artifact-path }} - if: ${{ inputs.artifact-name != '' }} - - - name: Prepare - run: ${{ inputs.prepare-command }} - if: ${{ inputs.prepare-command != '' }} - - - name: Set Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - - name: Install dependencies - working-directory: ${{ inputs.working-directory }} - run: npm install - - - name: Lint the project - working-directory: ${{ inputs.working-directory }} - run: npm run lint - if: ${{ inputs.lint }} - - - name: Format the project - working-directory: ${{ inputs.working-directory }} - run: npm run format - if: ${{ inputs.format }} - - - name: Test the project - working-directory: ${{ inputs.working-directory }} - run: npm run test - if: ${{ inputs.test }} - - - name: Build the project - working-directory: ${{ inputs.working-directory }} - run: npm run build - if: ${{ inputs.build }} - - - name: Cleanup - run: ${{ inputs.cleanup-command }} - if: ${{ inputs.cleanup-command != '' && always() }} diff --git a/.github/workflows/validate-workflows.yml b/.github/workflows/validate-workflows.yml index 77104cd..7dce858 100644 --- a/.github/workflows/validate-workflows.yml +++ b/.github/workflows/validate-workflows.yml @@ -1,9 +1,9 @@ -name: "Validate Workflow Files" +name: 'Validate Workflow Files' on: push: paths: - - ".github/workflows/*.yml" + - '.github/workflows/*.yml' jobs: validate-workflows: diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index c12cc2e..7bdb6fe 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -2,10 +2,15 @@ name: Versioning on: workflow_call: + inputs: + dry-run: + required: false + description: 'Whether to perform versioning without making a release' + type: string outputs: - next_version: - description: "Next version for tagging and releasing" - value: ${{ jobs.versioning.outputs.next_version }} + next-version: + description: 'Next version for tagging and releasing' + value: ${{ jobs.versioning.outputs.next-version }} jobs: versioning: @@ -15,7 +20,7 @@ jobs: pull-requests: write issues: write outputs: - next_version: ${{ steps.semantic.outputs.new_release_version }} + next-version: ${{ steps.semantic.outputs.new_release_version }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -23,5 +28,7 @@ jobs: - name: Semantic Release uses: cycjimmy/semantic-release-action@v4 id: semantic + with: + dry_run: ${{ inputs.dry-run }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index cf230c2..c2dee76 100644 --- a/README.md +++ b/README.md @@ -5,120 +5,134 @@ Common and Reusable GitHub Actions for the GEWIS organization. -## Docker build -Workflow for building a docker image. +> [!NOTE] +> All inputs for the workflows should be provided as strings. However, sometimes a certain structure is expected. These are noted in the "Options" columns. + +## Lint and build +Workflow for linting, formatting, testing and building projects. Can be used for both `npm` and `yarn`. -### Example ```yaml -name: Docker Build +jobs: + build-and-lint-yarn: + uses: GEWIS/actions/.github/workflows/lint-and-build-npm.yml@v1.0.0 + with: + node-version: '22.x' + format: true + + build-and-lint-npm: + uses: GEWIS/actions/.github/workflows/lint-and-build-yarn.yml@v1.0.0 + with: + node-version: '20.x' + test: true +``` + +### Inputs + +| Input name | Description | Required | Options | Default value | +|-------------------|--------------------------------------------------------------|----------|------------------------|---------------| +| working-directory | The directory where the project is located. | ☐ | | `.` | +| node-version | The version of Node.js to use. | ☐ | `18.x`, `20.x`, `22.x` | `20.x` | +| artifact-name | The name of the artifact to use. | ☐ | | | +| artifact-path | The path where the artifact should be stored. | ☐ | | | +| prepare-command | The command to run before building (and and after checkout). | ☐ | | | +| cleanup-command | The command to run after building. | ☐ | | | +| lint | Whether to lint the project. | ☐ | `true`, `false` | `true` | +| format | Whether to format the project. | ☐ | `true`, `false` | `false` | +| test | Whether to run tests. | ☐ | `true`, `false` | `false` | +| build | Whether to build the project. | ☐ | `true`, `false` | `true` | -on: - push: - branches: - - main - pull_request: - branches: - - main +## Docker build +Workflow for building a docker image. Useful for, for example, testing if a container build succeeds on a develop branch. +```yaml jobs: dockerize: - uses: GEWIS/actions/.github/workflows/docker-build.yml@v0.0.2 + uses: GEWIS/actions/.github/workflows/docker-build.yml@v1.0.0 with: projects: '["."]' ``` - -## Semantic release -Workflow for building Docker images and releasing them. Includes versioning using `semantic-release-action`. - ### Inputs -| Input name | Description | Required | Types/values | Default value | -|-----------------|----------------------------------------------------------|----------|--------------|---------------| -| projects | A comma-separated list of projects to release. | ☑ | `string` | N/A | -| docker-registry | The docker registry to push the build image to. | ☑ | `string` | N/A | -| docker-paths | The docker namespace, project and image name to push to. | ☑ | `string` | N/A | -| env_file | Contents of the environment file to use during building. | ☐ | `string` | N/A | +| Input name | Description | Required | Options | Default value | +|------------|----------------------------------------------|----------|---------|---------------| +| projects | Comma-separated list of projects to release. | ☑ | | | -### Secrets -| Secret name | Secret value | -|-------------------|--------------------------------------------| -| REGISTRY_USERNAME | The username used to push to the registry. | -| REGISTRY_PASSWORD | The password used to push to the registry. | -### Example +## Docker release +Workflow for building Docker images and releasing them. Can be used to push to GitHub and any other registry. ```yaml -name: Semantic release - -on: - pull_request: - branches: - - main - jobs: build-and-lint: - uses: GEWIS/actions/.github/workflows/semantic-release.yml@v0.0.2 + uses: GEWIS/actions/.github/workflows/docker-release.yml@v1.0.0 with: projects: '["."]' - docker_registry: 'abc.docker-registry.gewis.nl' - docker_tag: 'nc/aurora/core' + docker-registry: 'abc.docker-registry.gewis.nl' + docker-path: 'nc/aurora/core' + version: '4.0.40' + github-registry: 'true' ``` -## Lint and build -Workflow for linting, formatting, testing and building Typescript projects. - ### Inputs -| Input name | Description | Required | Types/values | Default value | -|-------------------|--------------------------------------------------------------|----------|------------------------|---------------| -| working-directory | The directory where the TypeScript project is located. | ☐ | `string` | `.` | -| node-version | The version of Node.js to use. | ☐ | `18.x`, `20.x`, `22.x` | `20.x` | -| package-manager | The package manager to use. | ☐ | `npm`, `yarn` | `npm` | -| artifact-name | The name of the artifact to use. | ☐ | `string` | N/A | -| artifact-path | The path where the artifact should be stored. | ☐ | `string` | N/A | -| prepare-command | The command to run before building (and and after checkout). | ☐ | `string` | N/A | -| cleanup-command | The command to run after building. | ☐ | `string` | N/A | -| lint | Whether to lint the project. | ☐ | `boolean` | `true` | -| format | Whether to format the project. | ☐ | `boolean` | `false` | -| test | Whether to run tests. | ☐ | `boolean` | `false` | -| build | Whether to build the project. | ☐ | `boolean` | `true` | - -### Example +| Input name | Description | Required | Options | Default value | +|-----------------|----------------------------------------------------------|----------|-----------------|---------------| +| projects | Comma-separated list of projects to release. | ☑ | | | +| version | Version of the Docker release. | ☑ | | | +| docker-registry | The docker registry to push the build image to. | ☑ | | | +| github-registry | Whether to push the image to the GitHub registry. | ☐ | `true`, `false` | `false` | +| env-file | Contents of the environment file to use during building. | ☐ | | | +| docker-paths | The docker namespace, project and image name to push to. | ☑ | | | -```yaml -name: Lint and build +### Secrets -on: - push: - branches: - - develop - pull_request: - branches: - - develop +| Secret name | Secret value | +|--------------------|---------------------------------------------------| +| REGISTRY\_USERNAME | The username used to push to the custom registry. | +| REGISTRY\_PASSWORD | The password used to push to the custom registry. | +## NPM release +Workflow for releasing a NPM package on GitHub. + +```yaml jobs: build-and-lint: - uses: GEWIS/actions/.github/workflows/typescript-lint-and-build.yml@v0.0.2 + uses: GEWIS/actions/.github/workflows/npm-release.yml@v1.0.0 with: - node-version: '22.x' - package-manager: 'yarn' - format: true + version: '4.0.40' + lerna: 'true' ``` +### Inputs + +| Input name | Description | Required | Options | Default value | +|--------------|-----------------------------------------|----------|------------------------|---------------| +| node-version | The version of Node.js to use. | ☐ | `18.x`, `20.x`, `22.x` | `20.x` | +| version | Version of the NPM release. | ☑ | | | +| lerna | Whether the project is a lerna project. | ☐ | `true`, `false` | `false` | + + ## Versioning Workflow for versioning a project using `semantic-release-action`. -### Example ```yaml -name: Versioning - -on: - pull_request: - branches: - - main - jobs: build-and-lint: - uses: GEWIS/actions/.github/workflows/versioning.yml@v0.0.2 + uses: GEWIS/actions/.github/workflows/versioning.yml@v1.0.0 ``` +### Inputs + +| Input name | Description | Required | Options | Default value | +|------------|------------------------------------------------------|----------|----------|---------------| +| dry-run | Whether to run a dry run of the semantic versioning. | ☐ | `string` | `.` | + +### Outputs + +| Output name | Description | Options | Default value | +|--------------|-------------------------------------------|----------|---------------| +| next-version | The next semantic version of the project. | `string` | "" | + +## Examples + +Example workflows for building, versioning and releasing a project can be found in the [examples](./examples) directory. \ No newline at end of file diff --git a/examples/docker-build.yml b/examples/docker-build.yml new file mode 100644 index 0000000..e905984 --- /dev/null +++ b/examples/docker-build.yml @@ -0,0 +1,15 @@ +name: Docker Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + dockerize: + uses: GEWIS/actions/.github/workflows/docker-build.yml@1.0.0 + with: + projects: '["."]' \ No newline at end of file diff --git a/examples/lint-and-build.yml b/examples/lint-and-build.yml new file mode 100644 index 0000000..a1004cf --- /dev/null +++ b/examples/lint-and-build.yml @@ -0,0 +1,19 @@ +name: Lint and build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-lint: + uses: GEWIS/actions/.github/workflows/typescript-lint-and-build.yml@1.0.0 + with: + node-version: "22.x" + package-manager: "yarn" + lint: true + format: true + build: true \ No newline at end of file diff --git a/examples/npm-semantic-release.yml b/examples/npm-semantic-release.yml new file mode 100644 index 0000000..9fc55aa --- /dev/null +++ b/examples/npm-semantic-release.yml @@ -0,0 +1,25 @@ +name: Publish + +on: + workflow_dispatch: + push: + branches: + - 'main' + pull_request: + branches: + - 'main' + +jobs: + versioning: + uses: GEWIS/actions/.github/workflows/npm-release.yml@1.0.0 + with: + dry-run: 'true', + + publish-npm: + uses: GEWIS/actions/.github/workflows/npm-release.yml@1.0.0 + needs: versioning + if: ${{ needs.versioning.outputs.next_version != '' }} + with: + node-version: '22.x' + version: ${{ needs.versioning.outputs.next_version }} + lerna: 'true' \ No newline at end of file diff --git a/examples/semantic-release.yml b/examples/semantic-release.yml new file mode 100644 index 0000000..0cdd75c --- /dev/null +++ b/examples/semantic-release.yml @@ -0,0 +1,18 @@ +name: Semantic release + +on: + push: + branches: + - main + +jobs: + semantic-release: + uses: GEWIS/actions/.github/workflows/semantic-release.yml@1.0.0 + with: + projects: "['.']" + docker_registry: "abc.docker-registry.gewis.nl" + docker_paths: "['eou/plankapi']" + github-registry: "true" + secrets: + REGISTRY_USERNAME: ${{ secrets.SVC_GH_ABCEOU_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.SVC_GH_ABCEOU_PWD }} \ No newline at end of file