diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..21c157b --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,15 @@ +name: main +on: + push: + branches: [ main ] + workflow_dispatch: +permissions: + contents: write +jobs: + release: + name: release + uses: ./.github/workflows/step-release.yaml + merge: + needs: release + name: merge + uses: ./.github/workflows/step-merge.yaml \ No newline at end of file diff --git a/.github/workflows/step-merge.yaml b/.github/workflows/step-merge.yaml new file mode 100644 index 0000000..323070c --- /dev/null +++ b/.github/workflows/step-merge.yaml @@ -0,0 +1,17 @@ +name: merge +on: + workflow_call: +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - name: Merge into Develop ➡️ + uses: devmasx/merge-branch@master + with: + type: now + from_branch: main + target_branch: develop + message: Merge version bump into develop + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/step-release.yaml b/.github/workflows/step-release.yaml new file mode 100644 index 0000000..9590a3a --- /dev/null +++ b/.github/workflows/step-release.yaml @@ -0,0 +1,32 @@ +name: release +on: + workflow_call: +jobs: + release: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - name: Set-up User 🐵 + uses: fregante/setup-git-user@v2 + - name: Bump and Tag 🏷️ + run: | + npm version patch + git tag "$(cat package.json | jq -r '.version')" -m "[release] webapp-$(cat package.json | jq -r '.version')" + git push origin "$(cat package.json | jq -r '.version')" + echo "VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV + echo "MAJOR=$(cat package.json | jq -r '.version' | cut -d "." -f 1)" >> $GITHUB_ENV + echo "MINOR=$(cat package.json | jq -r '.version' | cut -d "." -f 2)" >> $GITHUB_ENV + echo "PATCHED=$((1 + $(cat package.json | jq -r '.version' | cut -d "." -f 3) ))" >> $GITHUB_ENV + # Note :: an env var cannot be accessed from a step that defines or updates it + - name: Release 📦 + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.VERSION }} + - name: Add -SNAPSHOT 📷 + run: | + jq '.version="${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCHED }}-SNAPSHOT"' package.json > /tmp/package.json + mv /tmp/package.json package.json + - name: Commit -SNAPSHOT 💾 + uses: stefanzweifel/git-auto-commit-action@v4 \ No newline at end of file diff --git a/package.json b/package.json index 2e29a1f..e4ae5cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webapp", - "version": "0.1.0", + "version": "0.1.0-SNAPSHOT", "scripts": { "dev": "next dev", "build": "next build",