diff --git a/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml new file mode 100644 index 00000000..f942f2fd --- /dev/null +++ b/.github/workflows/auto_release.yml @@ -0,0 +1,59 @@ +name: Auto-release + +on: + push: + branches: + - main + +jobs: + check_version: + name: Check the package version + runs-on: ubuntu-latest + outputs: + version_changed: ${{ steps.check_result.outputs.version_changed }} + new_version: ${{ steps.check_result.outputs.new_version }} + steps: + - name: Check out the code + uses: actions/checkout@v4 + with: + fetch-tags: true + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + - name: Check the package version + id: check_result + run: | + latest_release_version=$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/*") + current_version=$(node -p "require('./package.json').version") + if [[ "$latest_release_version" == "$current_version" ]]; then + echo "version_changed=false" >> $GITHUB_OUTPUT + else + echo "version_changed=true" >> $GITHUB_OUTPUT + echo "new_version=$current_version" >> $GITHUB_OUTPUT + fi + + create_release: + name: Create a release + needs: check_version + if: needs.check_version.outputs.version_changed == 'true' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Wait for "Push" workflow + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.ref }} + check-name: Push + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + - name: Download target branch + + run: curl -s -o spicetify-marketplace.zip https://codeload.github.com/${{ github.repository }}/zip/refs/heads/dist + - name: Publish the release + uses: softprops/action-gh-release@v1 + with: + tag_name: "v${{ needs.check_version.outputs.new_version }}" + generate_release_notes: true + files: spicetify-marketplace.zip diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 754e5b1e..afd64125 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,7 +3,6 @@ on: push: branches: - main - workflow_call: jobs: deploy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 10d2aa7d..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Release - -permissions: - contents: write - -on: - workflow_dispatch: - inputs: - new_version: - description: New version number - required: true - type: string - -jobs: - bump_version: - name: Bump version - runs-on: ubuntu-latest - steps: - - name: Check out the code - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - - name: Configure Git - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - name: Bump Package Version - run: npm version --no-git-tag-version ${{ github.event.inputs.new_version }} - - name: Commit Changes - run: | - git commit -am "chore: bump version to ${{ github.event.inputs.new_version }}" - git push origin HEAD - - build_and_push: - name: Build and push - needs: bump_version - uses: ./.github/workflows/push.yml - - create_release: - name: Create release - needs: build_and_push - runs-on: ubuntu-latest - steps: - - name: Download "dist" branch - run: curl -s -o spicetify-marketplace.zip https://codeload.github.com/${{ github.repository }}/zip/refs/heads/dist - - name: Publish Release - uses: softprops/action-gh-release@master - with: - tag_name: ${{ github.event.inputs.new_version }} - generate_release_notes: true - files: spicetify-marketplace.zip