Skip to content

Commit 6a4b1f9

Browse files
committed
fix: update pkg trigger, update docs, rm release
1 parent 1665473 commit 6a4b1f9

File tree

3 files changed

+35
-99
lines changed

3 files changed

+35
-99
lines changed

.github/workflows/package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Simple Package — Sequential macOS arm64 & Windows x64
22

33
on:
4-
workflow_dispatch: # manual trigger
4+
workflow_dispatch: # you can also manually trigger this workflow
55
push:
6-
tags: ["v*"]
6+
branches:
7+
- main
78

89
jobs:
910
build-macos-arm64:

.github/workflows/release.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

README.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ requirements.txt
1414
└─ workflows/
1515
├─ test.yml
1616
├─ package.yml
17-
├─ package-matrix.yml
18-
└─ release.yml
17+
└─ package-matrix.yml
1918
```
2019

2120
This example includes a package workflow; you'll implement it as a hands-on exercise.
@@ -65,7 +64,7 @@ YAML is a human-friendly data serialization standard for all programming languag
6564
- develop
6665
```
6766

68-
**Or**
67+
**Or the following expression, they are equivalent**
6968

7069
```yaml
7170
branches: [main, develop]
@@ -99,7 +98,7 @@ YAML is a human-friendly data serialization standard for all programming languag
9998
- Comments: Lines starting with `#` are comments and are ignored by parsers.
10099

101100
```yaml
102-
# This is a comment
101+
# This is a comment. It looks awesome.
103102
```
104103

105104
**Congrats!** You now have a basic understanding of YAML syntax, which is enough for you to read and understand GitHub Actions workflow files.
@@ -151,8 +150,9 @@ To define a job in GitHub Actions, you use the `jobs` keyword followed by a uniq
151150
- GitHub Actions provides a variety of hosted runners with different operating systems and configurations. The three most common options are:
152151
- `ubuntu-latest`: The latest stable version of Ubuntu Linux.
153152
- `windows-latest`: The latest stable version of Windows Server.
154-
- `macos-latest`: The latest stable version of macOS.
155-
You can choose a appropriate runner according to [the docs provided by GitHub](https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/choose-the-runner-for-a-job#choosing-github-hosted-runners) based on your project's requirements and the environment you need for your workflows.
153+
- `macos-latest`: The latest stable version of macOS.
154+
- You can choose a appropriate runner according to [the docs provided by GitHub](https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/choose-the-runner-for-a-job#choosing-github-hosted-runners) based on your project's requirements and the environment you need for your workflows.
155+
- You can also set up self-hosted runners if you need specific hardware or software configurations not available in GitHub's hosted runners.
156156
- `steps`: A list of steps that make up the job. Each step can either run a script or use an action.
157157

158158
#### Steps
@@ -167,14 +167,14 @@ steps:
167167
# This is a common first step in most workflows that need to work with the repository's code.
168168
- name: Checkout Repo
169169
uses: actions/checkout@v4
170-
170+
171171
# Set up Python environment - Automatically install Python for the job efficiently
172172
# In this way, you don't need to manually install Python using shell commands
173173
# This action step handles it for you.
174174
- name: Set up Python
175175
uses: actions/setup-python@v4
176176
with:
177-
python-version: "3.11"
177+
python-version: '3.11'
178178
179179
# Install dependencies
180180
# This step ensures that all necessary Python packages listed in requirements.txt are installed
@@ -231,20 +231,34 @@ You can try implement a simple sequential workflow that first builds macOS arm64
231231

232232
If you have finished composing or encountered some troubles, you may see `solutions/package.yml` — this builds the two packages in sequence and uploads two artifacts (`hello-macos-arm64` and `hello-windows-x64`).
233233

234-
## Release flow (automatic packaging and release assets)
234+
## Release flow (automatic packaging and upload assets to release)
235235

236-
The repository includes a pair of workflows to create a tag, publish a release, and attach build artifacts to the release:
236+
The repository includes a workflow that automatically builds packages for multiple OS/Python combinations and attaches the build artifacts to a GitHub Release.
237237

238-
- `release.yml` — creates a `vX.Y.Z` tag from the workflow_dispatch input and publishes a GitHub Release.
239238
- `package-matrix.yml` — runs packaging on `ubuntu`, `macos`, and `windows` using a matrix and attaches the build artifacts to the release when the workflow is triggered by the `release` event.
240239

241-
How it works:
240+
### Wait, your workflow need some permissions to upload assets to release
241+
242+
To allow the workflow to upload assets to a release, you need to grant it the necessary permissions. By default, GitHub Actions workflows have read-only access to the repository contents. To upload assets to a release, you need to ensure that the workflow has write permissions.
243+
244+
#### How to do that
245+
246+
1. Go to your repository on GitHub.
247+
2. Click on the "Settings" tab.
248+
3. In the left sidebar, click on "Actions" under the "Security" section.
249+
4. Scroll down to the "Workflow permissions" section.
250+
5. Select the option "Read and write permissions".
251+
6. Click the "Save" button to apply the changes.
252+
253+
### Now try to create a release
254+
255+
1. Go to the Releases section of the repository.
256+
2. Click on "Draft a new release".
257+
3. Enter a tag version (e.g., `v1.0.0`) and fill in the release title and description you like.
258+
4. Click on "Publish release".
242259

243-
1. Use the **Create Release** workflow in the Actions tab.
244-
2. The workflow will create the tag base on your input and publish the release; this publishes a `release` event.
245-
3. `package-matrix.yml` is configured to run when a release is published; it will build packages for each OS/Python combination in the matrix and attach each artifact to the release.
260+
Once the release is published, the `package-matrix.yml` workflow will automatically run (so do the workflow defined by `package.yml` that you have just implemented, but now let's focus on `package-matrix.yml`), building the packages for each OS/Python combination defined in the matrix and attaching the resulting artifacts to the release.
246261

247-
Notes:
262+
## The end
248263

249-
- The build artifacts are attached to the Release created by `release.yml`.
250-
- Packaging is also possible manually by running the `Package — Build & Upload using Matrix` workflow.
264+
Now you may return to our [Weekly Sharing Session Repo](https://github.com/CompPsyUnion/2526-weekly-session/tree/main/Contents/GitHubAction) and continue to the end of our today's session.

0 commit comments

Comments
 (0)