diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..e9a7c9c --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,17 @@ +name: CD + +on: + push: + tags: + - v* + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-slim + steps: + - uses: actions/checkout@v5 + - uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..abccf28 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + - push + +jobs: + tests: + name: Tests + runs-on: ubuntu-slim + steps: + - uses: actions/checkout@v5 + - id: create-datetime-tag + uses: ./ + - run: | + TAG="${{ steps.create-datetime-tag.outputs.tag }}" + echo "Tag created: $TAG" + + if [ -z "$TAG" ]; then + echo "❌ Error: Tag output is empty" + exit 1 + fi + + # Verify tag exists locally + if ! git tag -l | grep -q "^$TAG$"; then + echo "❌ Error: Tag $TAG not found locally" + exit 1 + fi + echo "✅ Tag exists locally" + + # Verify tag was pushed to remote + if ! git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then + echo "❌ Error: Tag $TAG not found on remote" + exit 1 + fi + echo "✅ Tag exists on remote" + + echo "✅ All tests passed!" diff --git a/README.md b/README.md index 3ff5254..4dc3157 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# create-datetime-tag \ No newline at end of file +# @actalog/create-datetime-tag + +Creates and pushes a git tag based on the current date and time. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..1a48e5d --- /dev/null +++ b/action.yml @@ -0,0 +1,27 @@ +name: '@actalog/create-datetime-tag' +author: Gabriel Rufino +description: 'Creates and pushes a git tag based on the current date and time.' +branding: + icon: tag + color: orange + +outputs: + tag: + description: 'The created tag name' + value: ${{ steps.create-tag.outputs.tag }} + +runs: + using: composite + steps: + - id: create-tag + shell: bash + run: | + TAG=$(date +%Y-%m-%d.%H-%M) + + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "Creating tag: $TAG" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "$TAG" -m "Auto-generated tag for $TAG" + git push origin "$TAG" + echo "Tag $TAG created and pushed successfully!"