From 3d63d0989191476493d6ec8cf5f17a25a8c260e7 Mon Sep 17 00:00:00 2001 From: Sylvain Blanc Date: Fri, 6 Oct 2023 16:51:39 +0200 Subject: [PATCH] improve release add workflow --- .../workflows/docker-image-test-branch.yml | 24 --------- .github/workflows/docker-image.yml | 23 +++++++-- package-lock.json | 4 +- package.json | 2 +- release.sh | 49 +++++++++++++++++++ 5 files changed, 70 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/docker-image-test-branch.yml create mode 100755 release.sh diff --git a/.github/workflows/docker-image-test-branch.yml b/.github/workflows/docker-image-test-branch.yml deleted file mode 100644 index b59f449..0000000 --- a/.github/workflows/docker-image-test-branch.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Docker CI Unstable -on: - push: - branches: [unstable] - pull_request: - branches: [unstable] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2.1.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Build Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: cyfershepard/jellystat:unstable diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c654d31..1fca20c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,9 +1,9 @@ name: Docker CI on: push: - branches: [main] - pull_request: - branches: [main] + tags: + - "v*.*.*" + branches: [ unstable ] jobs: build: @@ -14,9 +14,22 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: ${{ github.repository }} + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} - name: Set up QEMU uses: docker/setup-qemu-action@v3 - - name: Login to Docker Hub + - name: Log in to the Container registry uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -26,5 +39,5 @@ jobs: with: context: . push: true + tags: ${{ steps.meta.outputs.tags }} platforms: linux/amd64,linux/arm64,linux/arm/v7 - tags: cyfershepard/jellystat:latest diff --git a/package-lock.json b/package-lock.json index 897e4d5..673ca94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jfstat", - "version": "1.0.5", + "version": "1.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jfstat", - "version": "1.0.5", + "version": "1.0.8", "dependencies": { "@emotion/react": "^11.10.6", "@emotion/styled": "^11.10.6", diff --git a/package.json b/package.json index d7488de..04df835 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jfstat", - "version": "1.0.5", + "version": "1.0.8", "private": true, "dependencies": { "@emotion/react": "^11.10.6", diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..f6977a9 --- /dev/null +++ b/release.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +PREVIOUS_VERSION=$(git describe --abbrev=0 --tags) + +echo "Choose the version component to increment:" +echo "1. Major" +echo "2. Minor" +echo "3. Patch" + +read -p "Enter your choice: " choice + +case $choice in + 1) + # Increment the major version + MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1) + MAJOR=$((MAJOR + 1)) + NEW_VERSION="$MAJOR.0.0" + ;; + 2) + # Increment the minor version + MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1) + MINOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f2) + MINOR=$((MINOR + 1)) + NEW_VERSION="$MAJOR.$MINOR.0" + ;; + 3) + # Increment the patch version + MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1) + MINOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f2) + PATCH=$(echo "$PREVIOUS_VERSION" | cut -d. -f3) + PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + ;; + *) + echo "Invalid choice. Exiting." + exit 1 + ;; +esac + +# Tag message +TAG_MESSAGE="Release version $NEW_VERSION" + +# Create a new tag +git tag -a "$NEW_VERSION" -m "$TAG_MESSAGE" + +# Push the tag to the remote repository +git push origin "$NEW_VERSION" + +echo "Tag $NEW_VERSION has been created and pushed to the remote repository."