-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Auto tagging new version on GitHub and DockerHub
- Loading branch information
1 parent
c0d891d
commit 207e867
Showing
4 changed files
with
52 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,57 @@ | ||
|
||
name: Build and Publish Docker Image to Docker Hub | ||
name: Bump Version, Build and Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '20' | ||
|
||
- name: Ensure Dependencies are Installed | ||
run: | | ||
npm install -g semver | ||
sudo apt-get install jq -y | ||
- name: Strip 'v' prefix and bump version in package.json | ||
id: bump_version | ||
run: | | ||
cd client/ | ||
# Remove 'v' prefix and save temporary file | ||
current_version=$(jq -r '.version' package.json | sed 's/^v//') | ||
# Increment the version (adjust patch to minor/major as needed) | ||
new_version=$(npx semver $current_version -i patch) | ||
# Add 'v' prefix to new version | ||
prefixed_version="v$new_version" | ||
echo "Bumping version from v$current_version to $prefixed_version" | ||
# Update package.json with the prefixed version | ||
jq ".version = \"$prefixed_version\"" package.json > package_tmp.json && mv package_tmp.json package.json | ||
# Save new version in GitHub Actions environment | ||
echo "new_version=$prefixed_version" >> $GITHUB_ENV | ||
- name: Commit and push new version | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add client/package.json | ||
git commit -m "chore: bump version to ${{ env.new_version }}" | ||
# Tag the new version with the v-prefixed format | ||
git tag -a "${{ env.new_version }}" -m "Release ${{ env.new_version }}" | ||
git push origin main | ||
git push origin "${{ env.new_version }}" | ||
build: | ||
needs: bump-version | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -20,11 +64,12 @@ jobs: | |
- name: Log in to Docker Hub | ||
run: echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ciuse99 --password-stdin | ||
|
||
- name: Build and Push Docker Image (SuggestArr) | ||
- name: Build and Push Docker Image | ||
run: | | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--cache-from type=registry,ref=ciuse99/suggestarr:cache \ | ||
--cache-to type=registry,ref=ciuse99/suggestarr:cache,mode=max \ | ||
-t ciuse99/suggestarr:latest \ | ||
-f docker/Dockerfile . --push | ||
-t ciuse99/suggestarr:${{ env.new_version }} \ | ||
-f docker/Dockerfile . --push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,12 @@ | ||
name: Bump Version, Build and Publish Docker Image | ||
name: Build and Publish Docker Image to Docker Hub | ||
|
||
on: | ||
push: | ||
branches: | ||
- nightly | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '16' | ||
|
||
- name: Strip 'v' prefix and bump version in package.json | ||
id: bump_version | ||
run: | | ||
cd client/ | ||
# Remove 'v' prefix and save temporary file | ||
current_version=$(jq -r '.version' package.json | sed 's/^v//') | ||
# Increment the version (adjust patch to minor/major as needed) | ||
new_version=$(npx semver $current_version -i patch) | ||
# Add 'v' prefix to new version | ||
prefixed_version="v$new_version" | ||
echo "Bumping version from v$current_version to $prefixed_version" | ||
# Update package.json with the prefixed version | ||
jq ".version = \"$prefixed_version\"" package.json > package_tmp.json && mv package_tmp.json package.json | ||
# Save new version in GitHub Actions environment | ||
echo "new_version=$prefixed_version" >> $GITHUB_ENV | ||
- name: Commit and push new version | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add client/package.json | ||
git commit -m "chore: bump version to ${{ env.new_version }}" | ||
# Tag the new version with the v-prefixed format | ||
git tag -a "${{ env.new_version }}" -m "Release ${{ env.new_version }}" | ||
git push origin nightly | ||
git push origin "${{ env.new_version }}" | ||
build: | ||
needs: bump-version | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters