Skip to content

Commit

Permalink
fix(workflow): refactor all github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicconike committed Jun 13, 2024
1 parent baf85c6 commit effac0b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 35 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up GPG
run: |
gpg --batch --import <(echo "$GPG_PRIVATE_KEY")
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback --edit-key $GPG_KEY_ID trust quit
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -31,7 +42,6 @@ jobs:
- name: Semantic Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: semantic-release publish
38 changes: 18 additions & 20 deletions .github/workflows/steam-stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,34 @@ on:
- master

jobs:
check-release:
runs-on: ubuntu-latest
outputs:
latest_run: ${{ steps.check_release.outputs.latest_run }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check if Release Action is running
id: check_release
run: |
latest_run=$(gh run list --workflow=release.yml --branch=master --json conclusion --jq '.[0].conclusion')
echo "latest_run=$latest_run" >> $GITHUB_ENV
update-readme:
name: Steam Stats
runs-on: ubuntu-latest
needs: check-release
if: needs.check-release.outputs.latest_run == 'success'
container:
image: nicconike/steam-stats:master
image: nicconike/steam-stats:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: "pip"

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Update Steam Stats in README
run: python api/main.py
env:
Expand Down
29 changes: 17 additions & 12 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ plugins:
- [
"@semantic-release/exec",
{
"prepareCmd": "docker build -t nicconike/steam-stats:${nextRelease.version} . && docker build -t nicconike/steam-stats:master .",
"publishCmd": "docker push nicconike/steam-stats:${nextRelease.version} && docker tag nicconike/steam-stats:${nextRelease.version} nicconike/steam-stats:latest && docker push nicconike/steam-stats:master",
"prepareCmd": "docker build -t nicconike/steam-stats:${nextRelease.version} . && docker build -t nicconike/steam-stats:latest .",
"publishCmd": "docker push nicconike/steam-stats:${nextRelease.version} && docker tag nicconike/steam-stats:${nextRelease.version} nicconike/steam-stats:latest && docker push nicconike/steam-stats:latest",
},
]
verifyConditions:
- "@semantic-release/git"
- "@semantic-release/github"
- "@semantic-release/exec"
analyzeCommits:
- path: "@semantic-release/commit-analyzer"
releaseRules:
- type: "feat"
release: "patch"
- type: "hotfix"
release: "patch"
- type: "patch"
release: "patch"
- type: "minor"
release: "minor"
- type: "breaking"
release: "major"
- type: "feat"
release: "patch"
- type: "hotfix"
release: "patch"
- type: "patch"
release: "patch"
- type: "minor"
release: "minor"
- type: "breaking"
release: "major"
generateNotes:
- path: "@semantic-release/release-notes-generator"
writerOpts:
Expand All @@ -56,6 +57,10 @@ prepare:
changelogFile: "CHANGELOG.md"
publish:
- path: "@semantic-release/github"
assets:
- path: dist/*
label: "Distribution"
prerelease: "${version.startsWith('0.0.') ? 'true' : 'false'}"
- path: "@semantic-release/exec"
cmd: "docker push nicconike/steam-stats:${nextRelease.version} && docker tag nicconike/steam-stats:${nextRelease.version} nicconike/steam-stats:latest && docker push nicconike/steam-stats:latest"
success:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version_variable = ["api/main.py:__version__"]
upload_to_release = true
tag_format = "v{version}"
changelog_file = "CHANGELOG.md"
gpg_sign = true

[tool.semantic_release.branches.main]
match = "master"
Expand Down

0 comments on commit effac0b

Please sign in to comment.