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

Fix GithubCI by version bumping deprecated workflow actions #602

Merged
merged 9 commits into from
Nov 13, 2024
106 changes: 106 additions & 0 deletions .github/actions/install-taskwarrior/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This action definition may look complicated, but it only builds taskwarrior from the latest source release and installs it.
# The rest of the file is caching of results and checks to avoid ambiguous failure in case taskwarrior changes their release strategy.
name: Install Taskwarrior
description: Builds latests stable taskwarrior release install it
inputs:
secret_gh_token:
description: "GH token used for downloading the release asset"
required: true
rust_toolchain:
description: "Rust toolchain to compile taskwarrior with"
default: stable
runs:
using: "composite"
steps:
- name: Update apt
run: sudo apt-get update
shell: bash
- name: Install libuuid
run: sudo apt-get install uuid-dev uuid-runtime
shell: bash

- name: Download latest stable taskwarrior source release
# This pattern only matches assets with a [numbers and dots] version suffix
run: gh release download --repo "GothenburgBitFactory/taskwarrior" --pattern "task-[0-9.]*.tar.gz" --dir /tmp/download
shell: bash
env:
GH_TOKEN: ${{ inputs.secret_gh_token }}
- name: Ensure that we only got one release asset
run: |
number_of_assets=$(ls -1 /tmp/download | wc -l)
if [ $number_of_assets -ne 1 ]
then
echo "Expected exactly one release asset, got $number_of_assets instead"
exit 1
else
echo "Got expected number of release assets"
fi
shell: bash
- name: Move taskwarrior source to task.tar.gz
run: |
cd /tmp/download
find . -name "*.tar.gz" -exec mv {} task.tar.gz \;
shell: bash

- name: Calculate SHA256 of task.tar.gz source(version cache check)
id: calculate-task-sha256
run: echo "task_sha256=$(/usr/bin/sha256sum /tmp/download/task.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
shell: bash
- name: Restore cached taskwarrior build
id: cache-taskwarrior-restore
uses: actions/cache/restore@v4
with:
path: /tmp/task.deb
key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}-rust-${{ inputs.rust_toolchain }}

- name: Install rust toolchain and rust cache
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust_toolchain }}
override: false
- name: Extract taskwarrior source code
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: |
cd /tmp/download
# Remove the version suffix from extracted directory
tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;'
cd /tmp
mv download/task taskwarrior
rm -rf download
shell: bash
- name: Set selected rust toolchain as default for taskwarrior
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: rustup override set ${{ inputs.rust_toolchain }} --path /tmp/taskwarrior
shell: bash
- name: Compile and install taskwarrior
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: |
cd /tmp/taskwarrior
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release .
cmake --build build -j $(nproc)
cd build
# Create a stub debian package. WARNING: This package has no dependencies set
cpack -D CPACK_PACKAGE_CONTACT="stub" -D CPACK_PACKAGE_FILE_NAME="task" -G DEB
mv task.deb /tmp
cd /tmp
rm -rf /tmp/taskwarrior/
shell: bash
- name: Unset rust toolchain again
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: rustup override unset --path /tmp/taskwarrior
shell: bash
- name: Cache taskwarrior build result
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
id: cache-taskwarrior-save
uses: actions/cache/save@v4
with:
path: /tmp/task.deb
key: ${{ steps.cache-taskwarrior-restore.outputs.cache-primary-key }}

- name: Install taskwarrior
run: sudo dpkg -i /tmp/task.deb
shell: bash
- name: Test if installation worked
run: task --version
shell: bash
21 changes: 11 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Build
on: [pull_request]
on:
pull_request:
workflow_call:
jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -11,9 +13,6 @@ jobs:
target: x86_64-apple-darwin
rust_flags: ''
features: ''
binary_postfix: ''
upx_args: --best
strip: true
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
rust_flags: ''
Expand Down Expand Up @@ -54,21 +53,23 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 10.7
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
default: true
- uses: actions-rs/cargo@v1
override: true
- uses: clechasseur/rs-cargo@v2
with:
command: build
args: --release ${{matrix.features}} --target=${{ matrix.target }}
- name: Compress binaries
uses: svenstaro/upx-action@v2
with:
file: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }}
files: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }}
args: ${{ matrix.upx_args }}
strip: ${{ matrix.strip }}
# MacOS Compression disabled due to bug https://github.com/upx/upx/blob/44e4bd0b5454ff8aee1ff3376974dfe6014300d9/NEWS#L31
if: ${{ matrix.os != 'macOS-latest' }}
- name: Packaging binary
shell: bash
run: |
Expand All @@ -80,9 +81,9 @@ jobs:
shasum -a 256 taskwarrior-tui-${{ matrix.target }}.tar.gz > taskwarrior-tui-${{ matrix.target }}.sha256
fi
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: taskwarrior-tui
name: taskwarrior-tui-${{ matrix.target }}
path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz
- name: Releasing assets
if: startsWith(github.ref, 'refs/tags/')
Expand Down
Loading