diff --git a/.github/workflows/check-package-version.yml b/.github/workflows/check-package-version.yml new file mode 100644 index 00000000..084654f6 --- /dev/null +++ b/.github/workflows/check-package-version.yml @@ -0,0 +1,24 @@ +name: Check if package version is updated + +on: + pull_request: + branches: + - master +jobs: + start: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Check if version has been updated + id: check + uses: EndBug/version-check@v2.1.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + file-name: ./package.json + - name: Log when changed + if: steps.check.outputs.changed == 'true' + run: 'echo "Yayy!! Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' + - name: Log when unchanged + if: steps.check.outputs.changed == 'false' + run: echo "No version change :/ Please update version in package.json!" && exit 1 diff --git a/.github/workflows/docker.yml b/.github/workflows/release.yml similarity index 50% rename from .github/workflows/docker.yml rename to .github/workflows/release.yml index 38563fb4..b272665d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - + name: Get package version + id: get_version + run: echo version=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT - name: Build and push uses: docker/build-push-action@v4 @@ -28,7 +32,17 @@ jobs: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/skandha:latest + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/skandha:${{ steps.get_version.outputs.version }} + ${{ secrets.DOCKERHUB_USERNAME }}/skandha:latest + - + name: Create GitHub release + uses: "marvinpinto/action-automatic-releases@6273874b61ebc8c71f1a61b2d98e234cf389b303" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ steps.get_version.outputs.version }} + prerelease: false + title: Release ${{ steps.get_version.outputs.version }} - name: Trigger pipeline run: ${{ secrets.PIPELINE_TRIGGER }}