From 8c81491df3dc38ddf880fdf11a8343f2bfa280ed Mon Sep 17 00:00:00 2001 From: Joao Castro Date: Tue, 2 Jul 2024 23:44:08 -0300 Subject: [PATCH] initial commit --- .github/workflows/release-tag.yml | 55 +++++++++++++++++++++++++++++++ .github/workflows/validate-pr.yml | 48 +++++++++++++++++++++++++++ CHANGELOG.md | 12 +++++++ LICENSE | 21 ++++++++++++ README.md | 14 ++++++++ README.pt-br.md | 14 ++++++++ 6 files changed, 164 insertions(+) create mode 100644 .github/workflows/release-tag.yml create mode 100644 .github/workflows/validate-pr.yml create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 README.pt-br.md diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 0000000..0b53017 --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,55 @@ +name: Create Tag and Release + +on: + push: + branches: + - main + +jobs: + create-tag-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get the version from package.json + id: get_version + run: | + version=$(jq -r '.version' package.json) + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: Generate release notes + id: generate_release_notes + run: | + last_tag=$(git describe --tags --abbrev=0) + git log "$last_tag"..HEAD --pretty=format:'* [%h] - %s' --abbrev-commit > release_notes.md + release_notes=$(> "$GITHUB_OUTPUT" + + + - name: Create GitHub tag + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TAG_TOKEN }} + run: | + version=${{ steps.get_version.outputs.version }} + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git tag -a "v$version" -m "Release version $version" + git push origin "v$version" + + - name: Create GitHub release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TAG_TOKEN }} + with: + tag_name: "v${{ steps.get_version.outputs.version }}" + release_name: "v${{ steps.get_version.outputs.version }}" + body: "${{ steps.generate_release_notes.outputs.notes }}" + draft: false + prerelease: false diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml new file mode 100644 index 0000000..de14a6e --- /dev/null +++ b/.github/workflows/validate-pr.yml @@ -0,0 +1,48 @@ +name: Validate PR + +on: + pull_request: + branches: + - main + +jobs: + validate-changes: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Ensure the entire history is fetched + + - name: Fetch main branch + run: git fetch origin main + + - name: Check for required file changes + id: file_changes + run: | + # Get the list of files changed in the PR + files=$(git diff --name-only origin/main...HEAD) + + # Initialize variables + changelog_changed=false + packagejson_changed=false + + # Check if the required files are in the list of changed files + for file in $files; do + if [ "$file" == "CHANGELOG.md" ]; then + changelog_changed=true + fi + if [ "$file" == "package.json" ]; then + packagejson_changed=true + fi + done + + # Set output variables + echo "changelog_changed=$changelog_changed" >> "$GITHUB_OUTPUT" + echo "packagejson_changed=$packagejson_changed" >> "$GITHUB_OUTPUT" + + - name: Ensure required files are changed + if: steps.file_changes.outputs.changelog_changed == 'false' || steps.file_changes.outputs.packagejson_changed == 'false' + run: | + echo "ERROR: Both CHANGELOG.md and package.json must be modified in this PR." + exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..edfef46 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ + +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] - yyyy-mm-dd + +### Added + +- Adding github actions, changelog and readme files. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6cd97cc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 João Luiz de Castro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e555c7 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Simpler + +![Node.js](https://img.shields.io/badge/Node.js-v14.17.3-green) +![License](https://img.shields.io/badge/license-MIT-blue) + +Simpler é um servidor Node.js simples, projetado para fornecer uma base para iniciar rapidamente seus projetos de servidor. + +## Licença + +Este projeto está licenciado sob a Licença MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes. + +# Outras versões + +[Readme in Portuguese (PT-BR)](README.pt-br.md) \ No newline at end of file diff --git a/README.pt-br.md b/README.pt-br.md new file mode 100644 index 0000000..235862b --- /dev/null +++ b/README.pt-br.md @@ -0,0 +1,14 @@ +# Simpler + +![Node.js](https://img.shields.io/badge/Node.js-v14.17.3-green) +![License](https://img.shields.io/badge/license-MIT-blue) + +Simpler is a simple Node.js server, designed to rapidly provide a base to start your server projects. + +## License + +This project is licensed under the MID license. Check file [LICENSE](LICENSE) for more details. + +# Other versions + +[Readme em inglês (EN)](README.md) \ No newline at end of file