Adding Artifacts from GitHub Actions to Releases
GitHub Actions is a powerful tool for automating your workflows. One of the key features of GitHub Actions is the ability to create and upload artifacts. Artifacts are files or directories that you can save from your workflow runs. You can use these artifacts to store build outputs, test results, logs, or other important data.
You can also attach artifacts to releases in GitHub. This allows you to distribute the files or directories to your users or collaborators. By adding artifacts to releases, you ensure that everyone has access to the necessary files and data.
Creating and Uploading Artifacts
To create and upload an artifact, you need to use the actions/upload-artifact
action in your workflow.
name: Upload Artifact
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: echo "Building artifact..."
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: my-artifact
path: build/output
This workflow will upload the build/output
directory as an artifact named my-artifact
.
Adding Artifacts to Releases
Once you have an artifact uploaded, you can add it to a release by following these steps:
- Go to your repository on GitHub.
- Click on the **Releases** tab.
- Click on **Draft a new release**.
- Enter a tag name, release title, and description.
- Under **Assets**, click on **Upload an asset**.
- Select the artifact you want to upload from the list of artifacts.
- Click **Upload asset**.
- Click **Publish release**.
Artifact Considerations
- Artifacts are stored in GitHub for 90 days by default.
- You can increase the retention period up to 365 days in the repository settings.
- Artifacts can be downloaded from the releases page or the actions page.
Table of Comparison
Feature | GitHub Artifacts | GitHub Releases |
---|---|---|
Storage | GitHub servers | GitHub servers |
Retention Policy | Default: 90 days, maximum: 365 days | Default: 90 days, maximum: 365 days |
Access | Only accessible by workflow runs | Accessible by everyone |
Distribution | Limited to workflows | Used for distributing files to users |
By combining GitHub Actions and releases, you can create a seamless workflow for building, testing, and distributing your software. With the ability to create and upload artifacts, you can easily share important files and data with your collaborators and users.