Update super-linter.yml (#27) #73
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
name: Build, Package & Release | |
on: | |
push: | |
branches: [ main, develop ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache node_modules | |
id: cache-nodes-modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install project dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Upload build result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: build/ | |
package: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Restore node_modules | |
id: cache-nodes-modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Restore build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: build/ | |
- run: npm run package | |
- name: Upload packages artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: flixpatrol | |
path: bin/ | |
tag-new-versions: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: package | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Create new tag | |
id: new-tag | |
uses: salsify/action-detect-and-tag-new-version@v2 | |
outputs: | |
tag: ${{ steps.new-tag.outputs.tag }} | |
release: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: tag-new-versions | |
steps: | |
- name: Restore build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: flixpatrol | |
path: bin/ | |
- name: Build Changelog | |
id: github_release | |
uses: mikepenz/release-changelog-builder-action@v3 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body: ${{steps.github_release.outputs.changelog}} | |
name: ${{needs.tag-new-versions.outputs.tag}} | |
tag_name: ${{needs.tag-new-versions.outputs.tag}} | |
files: | | |
bin/flixpatrol-top10-linux | |
bin/flixpatrol-top10-macos | |
bin/flixpatrol-top10-win.exe | |
docker-main: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: tag-new-versions | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: flixpatrol | |
path: bin/ | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: PrepareReg Names | |
run: | | |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
# set latest tag for default branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ steps.meta.outputs.tags }} | |
${{ env.REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{needs.tag-new-versions.outputs.tag}} | |
labels: ${{ steps.meta.outputs.labels }} | |
docker-dev: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/develop' | |
needs: package | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: flixpatrol | |
path: bin/ | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }}, | |
labels: ${{ steps.meta.outputs.labels }} |