Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions/Workflows housekeeping #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ede4097
add setup-rust step
Lordfirespeed Dec 4, 2023
646ea48
update actions/checkout from v2 to v4
Lordfirespeed Dec 4, 2023
31d0053
update actions/setup-dotnet from v3 to v4
Lordfirespeed Dec 4, 2023
d40bcf7
reduce complexity of pure SemVer regex
Lordfirespeed Dec 4, 2023
5b4dccd
remove 'get tag' step from jobs that depend on `validate-tag`
Lordfirespeed Dec 4, 2023
5c4c5b4
add `.yml` entry to editorconfig
Lordfirespeed Dec 4, 2023
bc5ef4b
add `tag` step output to `validate-tag` job outputs
Lordfirespeed Dec 4, 2023
83e673c
replace references to `steps.tag.outputs.tag` with `needs.validate-ta…
Lordfirespeed Dec 4, 2023
6c8077b
hoist job names to top, add step names for `release` workflow
Lordfirespeed Dec 4, 2023
cce90fe
standardise whitespace between job steps for `release` workflow
Lordfirespeed Dec 4, 2023
b0bc3ba
add steps to setup Cargo before running build command
Lordfirespeed Dec 4, 2023
25b059b
add step names for `test` workflow
Lordfirespeed Dec 4, 2023
3fbe8df
standardise whitespace between job steps for `test` workflow
Lordfirespeed Dec 4, 2023
5c79546
use more appropriate job names in `release` workflow
Lordfirespeed Dec 4, 2023
a2c0591
add job name and step names to `publish` workflow
Lordfirespeed Dec 4, 2023
61cc94e
standardise whitespace in `publish` workflow
Lordfirespeed Dec 4, 2023
db4fffd
update fetch-gh-release-asset action and remove redundant default arg…
Lordfirespeed Dec 4, 2023
0945b9a
update to codecov v3
Lordfirespeed Dec 4, 2023
f2e3556
update triggers for the 'test' task
Lordfirespeed Dec 4, 2023
264f219
replace dawid66/action-get-tag with updated + verified fork devops-ac…
Lordfirespeed Dec 4, 2023
14b4887
add 'Build and Test' status badge
Lordfirespeed Dec 4, 2023
3f4e915
add NuGet package version badge
Lordfirespeed Dec 4, 2023
9dda3dc
add NuGet Downloads badge
Lordfirespeed Dec 4, 2023
5a503a9
update github-script action
Lordfirespeed Dec 6, 2023
ed7de60
Update test workflow branch name
MythicManiac Dec 6, 2023
1aa4084
Run pre-commit
MythicManiac Dec 6, 2023
c18cd03
Add codecov token to test workflow
MythicManiac Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ charset = utf-8
indent_style = space
indent_size = 4

[*.yml]
indent_size = 2

[*.{cs,vb}]
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
csharp_new_line_before_open_brace = all
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ on:

jobs:
nuget:
name: Publish NuGet Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'

- name: Fetch Latest .nupkg
uses: dsaltares/fetch-gh-release-asset@0efe227dedb360b09ea0e533795d584b61c461a9
uses: dsaltares/fetch-gh-release-asset@1.1.1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
version: "tags/${{ github.ref_name }}"
file: "tcli.${{ github.ref_name }}.nupkg"
target: "tcli.nupkg"


- name: Publish to NuGet
shell: bash
run: dotnet nuget push tcli.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
58 changes: 38 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ on:
jobs:
# Validate tag with proper regex since the check above is very limited.
validate-tag:
name: Validate tag semantic version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v2
- id: tag
uses: dawidd6/action-get-tag@v1
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: Ensure triggering ref is a tag
id: tag
uses: devops-actions/[email protected]

- id: regex-match
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ steps.tag.outputs.tag }}
regex: '^([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])$'
regex: '^([1-9][0-9]*|0)\.([1-9][0-9]*|0)\.([1-9][0-9]*|0)$'

- id: fail-fast
if: ${{ steps.regex-match.outputs.match == '' }}
uses: actions/github-script@v3
uses: actions/github-script@v7
with:
script: core.setFailed('Tag is invalid')

platform-binary:
name: Build binaries for ${{ matrix.target }}
needs: validate-tag
if: github.event.base_ref == 'refs/heads/master'
name: Create binary ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -43,19 +51,24 @@ jobs:
target: osx-x64
os: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- id: tag
uses: dawidd6/action-get-tag@v1

- name: Install dependencies
run: dotnet restore

- name: Setup Cargo/Rust
uses: moonrepo/setup-rust@v1

- name: Build
shell: bash
run: |
release_name="tcli-${{ steps.tag.outputs.tag }}-${{ matrix.target }}"
release_name="tcli-${{ needs.validate-tag.outputs.tag }}-${{ matrix.target }}"
dotnet publish ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -r "${{ matrix.target }}" --self-contained true -f net7.0 -o "${release_name}"

if [ "${{ matrix.target }}" == "win-x64" ]; then
Expand All @@ -66,39 +79,44 @@ jobs:

rm -r ${release_name}

- name: Publish to GitHub
- name: Add build artifacts to draft GitHub release
uses: softprops/action-gh-release@v1
with:
files: "tcli*"
name: "Thunderstore CLI ${{ steps.tag.outputs.tag }}"
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
draft: true
prerelease: ${{ startsWith(steps.tag.outputs.tag, '0.') }}

nupkg:
name: Build NuGet Package
needs: validate-tag
if: github.event.base_ref == 'refs/heads/master'
name: Create .nupkg
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- id: tag
uses: dawidd6/action-get-tag@v1

- name: Install dependencies
run: dotnet restore

- name: Setup Cargo/Rust
uses: moonrepo/setup-rust@v1

- name: Build
shell: bash
run: dotnet pack ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -o "." -p:EnableInstallers=false -p:PublishSelfContained=false -p:PublishSingleFile=false -p:PublishTrimmed=false -p:PublishReadyToRun=false

- name: Publish to GitHub
- name: Add build artifacts to draft GitHub release
uses: softprops/action-gh-release@v1
with:
files: "tcli*"
name: "Thunderstore CLI ${{ steps.tag.outputs.tag }}"
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
draft: true
prerelease: ${{ startsWith(steps.tag.outputs.tag, '0.') }}
40 changes: 32 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
name: Build & Test

on: [push]
on:
# Trigger on pushes to the main branch
push:
branches: [ master ]
# Trigger on any pull request
pull_request:

jobs:
pre-commit:
name: Code style check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- uses: actions/setup-python@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install pre-commit

- name: Install pre-commit framework
run: curl https://pre-commit.com/install-local.py | python -

- name: Install dotnet-format
run: dotnet tool install -g dotnet-format

- name: Run pre-commit
run: ~/bin/pre-commit run --show-diff-on-failure --color=always --all-files

Expand All @@ -30,19 +43,30 @@ jobs:
env:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4

- name: setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'

- name: Setup Cargo/Rust
uses: moonrepo/setup-rust@v1

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Run xUnit tests
run: dotnet test -p:EnableInstallers=false --collect:"XPlat Code Coverage"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
directory: ./ThunderstoreCLI.Tests/TestResults/
env_vars: OS
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# thunderstore-cli

[![Build & Test](https://github.com/thunderstore-io/thunderstore-cli/actions/workflows/test.yml/badge.svg)](https://github.com/thunderstore-io/thunderstore-cli/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/thunderstore-io/thunderstore-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/thunderstore-io/thunderstore-cli)
[![NuGet Package](https://img.shields.io/nuget/v/tcli)](https://www.nuget.org/packages/tcli)
[![downloads](https://img.shields.io/nuget/dt/tcli)](https://www.nuget.org/packages/tcli)

Thunderstore CLI (just "TCLI" from here on) is a command line tool for building and uploading mod packages to
[Thunderstore](https://thunderstore.io/) mod database, and installing mods via the command line.
Expand Down
Loading